Tag: select2 rails

select2-rails + act_as_taggable_on rails 4问题

我在我的应用程序中安装了select2-rails和act_as_taggable_on gem。 我设置了act_as_taggable_on并且它可以工作(我从控制台测试)。 但是,当我尝试创建视图以便用户可以添加新标记时,它无法正常工作。 我想做一个像这样的标记支持: https : //select2.github.io/examples.html#tokenizer 。 这是我的设置: 应用程序/资产/ application.js中 $(document).ready(function(){ $(“.multiple-input”).select2({ theme: “bootstrap”; tags: true; tokenSeparators: [‘,’] }) }); 应用程序/视图/型材/ new.html.erb 当我在浏览器上打开profiles / new时,skill_list文本字段显示为它的方式,而不是使用select2标记系统。 我的代码肯定有问题或遗漏。 请帮忙。 更新1 我将代码更改为: 没运气。 所以,我安装了简单的表单gem,因为基于这篇文章( http://onewebstory.com/notes/user-friendly-tagging-on-rails),select2 rails不适用于select标签。 这是我目前的代码: 应用程序/视图/型材/ new.html.erb 应用程序/资产/ application.js中 $(document).ready(function() { $(‘input.multiple-input’).each(function() { $(this).select2({ theme: ‘bootstrap’, tags: $(this).data(‘tags’), tokenSeparators: [‘,’] }); }); }); select2正在工作,我可以使用select2搜索和下拉列表。 […]

Rails 5 ask_as_taggable with select2

我无法看到select2在rails 5中的效果,无论是text_field还是select。 有谁知道为什么没有填充tag_list。 我可以看到tag_list有值,但正如您在下面的快照中看到的那样,它显示“未找到结果”。 select2是否适用于Rails 5,因为我尝试了几个选项? form:选择all将在框中显示所有值 Select All 我使文本字段变得简单而不是select2,并且能够通过将:tag_list添加到强参数来在DB中添加标签。 application.js – 注意:select2没有用o我使用了select2-full,我在谷歌的某个地方看过。 //= require underscore //= require select2-full select2的JS代码 $(function() { $(‘input#post_tag_list’).select2({tags:[], placeholder: “Choose a Tag”, allowClear: true}) }); 现在,我检查了普通的HTML和JS它甚至使用select2(或select2-full) Apple Banana Grapes Select All 相应的JS代码是: $(“#checkbox”).click(function(){ if($(“#checkbox”).is(‘:checked’) ){ $(“#post_topic_list > option”).prop(“selected”,”selected”); $(“#post_topic_list”).trigger(“change”); }else{ $(“#post_topic_list > option”).removeAttr(“selected”); $(“#post_topic_list”).trigger(“change”); } }); 有人可以指出普通的HTML选择输入是否与select2一起工作为什么它在rails 5中没有相同的function? 我尝试了bootstrap_form_for和form_for。 我甚至读过有关turbolinks问题的内容……如何解决turbolinks没有加载select2的问题?

select2-rails gem不能在Rails4上运行

我已经尝试过select2-rails gem的文档,但是我的浏览器控制台仍然会抛出错误。 未捕获的TypeError:$(…)。select2不是函数 我使用的是rails 4.0.1和select2-rails 3.5.9.3 我的application.js //= require jquery //= require select2 //= require jquery.ui.accordion //= require jquery.ui.menu //= require jquery.ui.datepicker //= require common //= require posts //= require twitter/bootstrap //= require owl.carousel //= require turbolinks //= require vendor_js //= require_tree . $(document).ready(function() { $(“select#team_select”).select2(); }); application.css *= require select2 *= require_self *= require […]