javascript - data source in x-editable doesn't work -
i'm trying implement x-editable rails project , want use list of participants come db source of 'select' question.
i've read documentation , states source option accepts array of objects, i'm formatting list accordingly. unfortunately, 'select' field appears blank if source not recognized.
since i'm using x-editable-rails gem implement thought problem on how gem rendering html data attributes. however, when inspected element in browser console don't see what's problem.
my rendered html
<span class="editable editable-click editable-empty" title="participant" data-type="select" data-model="answer" data-name="participant_id" data-value="" data-placeholder="participant" data-source="[{"id":1,"username":"shari","created_at":"2017-08-15t11:23:26.692z","updated_at":"2017-08-15t11:23:26.692z"},{"id":2,"username":"mireya ","created_at":"2017-08-15t11:23:41.760z","updated_at":"2017-08-15t11:23:41.760z"},{"id":3,"username":"edgar ","created_at":"2017-08-15t11:23:53.356z","updated_at":"2017-08-15t11:23:53.356z"}]" data-url="/answers/2">empty</span> x-editable documentation advice
[{value: 1, text: "text1"}, {value: 2, text: "text2"}, ...] could advise on potential solution?
i've found mistake. misread documentation. keys of hashes within array must take values "value" , "text" literally. html must render:
[{:value=>1, :text=>"shari"}, {:value=>2, :text=>"mireya "}, {:value=>3, :text=>"edgar "}, {:value=>"", :text=>"none"}]
Comments
Post a Comment