jQuery tokenInput未预填充text_field [英] Jquery tokenInput not prepopulating the text_field

查看:80
本文介绍了jQuery tokenInput未预填充text_field的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有tokenInput文档,但在编辑时不知为何我的text_field category_tokens未预先填充类别.

Hi I've tokenInput documentation but somehow my text_field category_tokens is not prepopulated with categories while editing.

这是代码段

<input id="product_category_tokens" type="text" size="30" name="product[category_tokens]" data-pre="[{"created_at":"2010-09-13T03:33:17Z","description":"","id":x,"name":"Kitchen & Dining ","parent_id":xx,"permalink":"kitchen-dining","updated_at":"2011-01-05T11:17:10Z"}]" style="display: none;">

$(function() {
  $("#product_category_tokens").tokenInput("/categories.json", {
      crossDomain: false,
      prePopulate: $('#product_category_tokens').data('pre'),
      preventDuplicates: true
  });
});

<%= f.text_field :category_tokens, "data-pre" => @product.categories.map(&:attributes).to_json %>

任何指针都值得赞赏!

推荐答案

更改

<%= f.text_field :category_tokens, "data-pre" => @product.categories.map(&:attributes).to_json %>

<%= f.text_field :category_tokens, input_html => { "data-pre" => @product.categories.map(&:attributes).to_json } %>

这篇关于jQuery tokenInput未预填充text_field的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆