bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 574 forks source link

Selection box not working in Rails 4 - and how to make it work #549

Open chrilleferna opened 8 years ago

chrilleferna commented 8 years ago

Even the simplest selects don't work for me in Rails 4 and version 3.0.3 of the gem: when loading the page the correct value is shown, but when clicking on the selection, a very tall selection box comes up with empty options. Looking into the generated HTML I can see that the quoted strings (e.g. if you have :collection => {1 => "Spain", ...) appear as "Spain". i.e. the quotes have been escaped.

I found that this comes from line 30 in lib/best_in_place/helper.rb where html_escape is applied to collection. If you remove html_escape and change this line into:

options[:data]['bip-collection'] = collection`

things work as they should. I'm not sure if that has other, undesired, effects, but this works for me. I suggest that the gem author takes a look.