如何在act_as_taggable_on和formtastic中使用令牌字段?

| 我希望能够以形式将令牌字段(在此处找到:http://railscasts.com/episodes/258-token-fields)使用,以允许用户输入标签(我正在使用acts_as_taggable_on)。 有人可以引导我了解如何执行此操作的示例吗?     
已邀请:
我没有时间进行完整的遍历,但是胆量似乎是
text_field
具有
data-pre
属性,其中包含一些JSON。在Formtastic中向输入添加属性的方法是通过:input_html选项,因此:
<p>
  <%= f.label :author_tokens, \"Authors\" %><br />
  <%= f.text_field :author_tokens, \"data-pre\" => @book.authors.map(&:attributes).to_json %>
</p>
可能会翻译成以下内容:
<%= f.input :author_tokens, :input_html => { \"data-pre\" => @book.authors.map(&:attributes).to_json } %>
剩下的就是将CSS粘贴到HTML并找到合适的DOM元素以将jQuery应用于(查看源是您的朋友)。     

要回复问题请先登录注册