0
你好,我叫下面this tutorial但预填充字段在编辑我的模型..Jquery的tokenInput不预先填充
注意text_field category_tokens没有预先填充编辑时,一类是不工作。
以下是代码片段,text_field的HTML输出显示值。
<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;">
application.js
$(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 %>
你的开发日志是什么样的?来自categories.json的任何错误? – 2011-06-16 21:01:25
categories.json显示正确的json格式。实际上,该插件用于创建新类别。这只是在编辑产品时不预先填充当前类别。 – anshu 2011-06-17 17:34:58
它应该从该json网址预先填充。你确定你遵循了指南吗? – 2011-06-17 17:40:28