An open API service indexing awesome lists of open source software.

https://github.com/ekylibre/combo_box

Adds the combo_box control in Rails 3 based on jQuery UI
https://github.com/ekylibre/combo_box

Last synced: about 2 months ago
JSON representation

Adds the combo_box control in Rails 3 based on jQuery UI

Awesome Lists containing this project

README

        

= ComboBox

Adds helpers for Rails views and controller in order to manage 'dynamic select'. It uses jQuery UI as support for inobtrusive use in forms. It's not the classic Autocompleter, its use is limited to belongs_to reflections.

== Rails 3.0

ComboBox requires the gem +jquery-rails+, so if you don't already use it:
rails generate jquery:install --ui

Then install +combo_box+ in your app like +jquery-rails+:
rails generate combo_box:install

Then the javascript and/or stylesheet files must be included in the application layout:
<%= javascript_include_tag('combo_box') -%>
<%= stylesheet_link_tag('combo_box') -%>

== Rails 3.1

Nothing to install. With the asset pipeline, there is no need to run generators or copy files. So for stylesheets:
# app/assets/stylesheets/application.css
*= require combo_box

And for javascripts:
# app/assets/javascripts/application.js
//= require combo_box

== Usage

Classic usage in resource forms:

# app/controllers/orders_controller.rb
class OrdersController < ApplicationController
search_for :client
end

# app/views/orders/_form.html.haml
combo_box :order, :client

Usage in non-resource forms with personalized controller method:

# app/controllers/orders_controller.rb
class OrdersController < ApplicationController
def search_for_orders
orders = Order.find_all_by_number(params[:term])
render orders.collect{|r| {:label=>r.number, :id=>r.id}}.to_json
end
end

# app/views/orders/search.html.haml
combo_box_tag "search", :search_for_orders

== Contributing to ComboBox

* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2011 Brice Texier. See LICENSE.txt for
further details.