How to use jquery tokeninput in Rails?

前提是你 提交于 2019-12-05 08:24:14

If you are using acts_as_taggable_on gem it's easier way than in railscast.

Model (Post):

acts_as_taggable_on :works

View (form):

= f.text_field :work_list, "data-pre" => f.object.work_list.sort.collect {|t| {id: t, name: t } }.to_json

JS:

$ ->
  $("#post_work_list").tokenInput "/posts/works.json",
    preventDuplicates: true,
    animateDropdown: false
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!