werein / x-editable-rails

Edit fields easily with X-Editable helper

Home Page:https://wereinhq.com/guides/x-editable-rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checklist functionality - Not sure if I'm being thick

theangryangel opened this issue · comments

commented

Taking the example of #28, the following code works, with 1 issue: The helper correctly displays the city names, however clicking on the names, the selected items are not checked.

editable @common_app, :city_ids, url: user_common_app_path(@user,@common_app), type: "checklist", value: @common_app.cities.map{|city| city.name}, source: City.all.map{ | city | {value: city.id, text: city.name} }

Switching the value to be defined as @common_app.cities.map{|city| city.id } results in the checkboxes being correctly checked, but the initial value displayed on the page is now the list of ids, rather than the cities.

This is somewhat problematic.

I don't know if it's just because it's the end of a long day, or if I'm simply fundamentally misunderstanding how the view helper is written but looking at https://github.com/werein/x-editable-rails/blob/master/lib/x-editable-rails/view_helpers.rb#L75-L78 I'm not seeing an obvious solution.

I'm happy to write the patch (if I'm not being super retarded), if I'm pointed in the right direction.

commented

Ended up removing x-editable-rails in the project, issue no longer relevant to me.