令牌输入重构,现在不会被搜索

时间:2014-07-29 16:33:35

标签: javascript ruby-on-rails coffeescript

  $('.token_input').each ->
    t = $(this)
    t.tokenInput t.data('url'),
      crossDomain: false
      prePopulate: t.data('load')
      preventDuplicates: true
      minChars: 4
      theme: 'facebook'

正如您所看到的,我重构了token_input,因此如果需要,我可以轻松地将其添加到多个字段中。它确实有效,它将字段更改为令牌字段,但是当我搜索时它没有进行对齐。

我在咖啡中有这个脚本所以我不确定我是否在这里遗漏了一些东西。谢谢!

这是原始代码(有效)。

  $('#restaurant_cooking_style_id').tokenInput('/cooking_styles.json',
    { crossDomain: false, prePopulate: $('#restaurant_cooking_style_id').data('load'), preventDuplicates:true, theme: 'facebook', minChars: 4 }
    )


<%#= f.text_field :cooking_style_id, class: 'token_input', data: { url: '/cooking_styles.json'}, data: { load: @restaurant.cooking_styles.collect { |cooking_style| {:id => cooking_style.id, :name => cooking_style.style } } } %>

0 个答案:

没有答案