我正在尝试在我的项目中实现 select2 功能。它没有正确渲染。我正在粘贴我的代码,请告诉我哪里出错了
<div class="form-group">
<label for="userInputCollegeName">College Name</label>
<%= f.collection_select(:college_id, College.all, :id, :name, {:prompt => 'Select the college'}) %>
</div>
<script>$(document).ready(function() {
$("#user_college_id").select2({theme: "bootstrap"});
});</script>
在我的 html 中,collection_select 的 id 是user_college_id
.
我正在添加一张图片:
我知道第一个选择是因为 collection_select 标签,第二个字段是因为 select2,但我不需要第一个。
我只需要 select2 字段。我们怎么能做到这一点?任何帮助表示感谢谢谢!