How to use Best In Place with twitter bootstrap

I have not seen any documentation from this.

If i have

<%= best_in_place @user, :city,  type=> :input, %>

I need to enable data-supply = "typeahead"

<%= best_in_place @user, :city, type=> :input,:data => {:provide => "typeahead"} %>

and turn on the source

<%= best_in_place @user, :city, :type=> :input, :data => {:provide => "typeahead", :source => City.getcities.to_json} %>

Suppose it City.getcities.to_jsonreturns the correct json list with city names

This does not work...

+2
source share
1 answer

Using the option, :datayou can set the attributes data-in the generated span, not on input.

If you want to add attributes to the generated element input, you need to use the options :html_attrs:

<%= best_in_place @user, :city, :type=> :input, 
    :html_attrs => {:'data-provide' => "typeahead", 
                    :'data-source' => City.getcities.to_json} %>

- @Nick Ginanto - typeahead , (, - bootstrap )

, , :

$('ul.typeahead').live('mousedown', function(e) { e.preventDefault(); });
+4

All Articles