Tag: selectize.js

Ruby on Rails:Selectize.js与Cocoon

我正在尝试在Ruby on Rails中创建一个表单来选择构造的一部分。 新的字段(部分条目 – 连接表)由Cocoon gem添加。 一切正常,但在尝试编辑保存的结构时,Selectize无法读取其当前部分的字段。 这是我的_part_fields.html.erb: “Select or create a part…”}, {class => “construction_part_select”} %> application.js中: //= require jquery //= require jquery.turbolinks //= require jquery_ujs //= require selectize //= require bootstrap //= require bootstrap-sprockets //= require cocoon //= require_tree . jQuery(function () { console.log(“jQuery”); $(“#construction_part_select”).each(function () { console.log(“iter1”); $(this).selectize({ create: true, sortField: […]

TypeError:$(…)。selectize不是函数

我在我的rails应用程序中安装了“selectize-rails”gem,我正试图让它工作。 我一直在我的网络控制台中收到此错误: TypeError: $(…).selectize is not a function 并且浏览器中没有任何反应。 这是我到目前为止的代码,遵循此页面中的“电子邮件联系人”示例: http : //brianreavis.github.io/selectize.js/ 意见/电子邮件/ new.html.erb $(document).ready(function() { console.log( typeof $.fn.selectize === ‘function’); // true console.log( $(‘#select-to’).length === 1 ); // true var REGEX_EMAIL = ‘([a-z0-9!#$%&\’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\’*+/=?^_`{|}~-]+)*@’ + ‘(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)’; $(‘#select-to’).selectize({ persist: false, maxItems: null, valueField: ’email’, labelField: ‘name’, searchField: [‘name’, ’email’], options: [ {email: ‘brian@thirdroute.com’, name: ‘Brian […]