select2-rails gem似乎在我的项目中出现浏览器返回功能问题:
表单中的select2-choices将加倍:image of bug
的Gemfile:
ruby 2.3.1
rails 5.0.0.1
gem select2-rails 4.0.3
查看:
<head>
<script>
$(document).ready(function() {
$(".multi_select").select2({ theme: bootstrap", placeholder: "Bitte mindestens 1 auswählen"
});
});
</script>
</head>
<%=form_tag( practices_path, method: "get", remote: true ) do %>
<div class="form-group">
<%=label_tag(:category_ids, "Kategorien:") %>
<%=select_tag( 'category_ids', options_from_collection_for_select(@categories, "id", "name"), class: "multi_select", multiple: true, style: "width: 100%", autocomplete: 'off' ) %>
</div>
.
.
.
<div class="form-group">
<%= label_tag(:area_ids, "Räume:") %>
<%= select_tag( 'area_ids',
options_from_collection_for_select(@areas, "id", "name"),
class: "multi_select", multiple: true, style: "width: 100%" ) %>
</div>
<div class="form-group row">
<%=submit_tag( "Filter anwenden", class: "btn btn-primary" ) %>
<%=link_to "Filter zurücksetzen", root_path, class: "btn btn-default", style: "float: right" %>
</div>
<% end %>
控制器:
class PracticesController < ApplicationController
.
.
.
def index
@categories = Category.all
@areas = Area.all
@practices = Practice.with_category(params[:category_ids])\
.with_participants(params[:participants])\
.with_min_duration(params[:min_duration])\
.with_max_duration(params[:max_duration])\
.with_age(params[:age])\
.with_areas(params[:area_ids])\
.paginate(:page => params[:page])
respond_to do |format|
format.html
format.js
end
end
.
.
.
end
删除以下代码段,但将该部分留在“{}” - &gt;之间形式不使用select2-styling
$(document).ready(function() { ... });
添加autocomplete: 'off'
- &gt;没有区别
如何在我的测试中使用浏览器返回功能来查找错误? (我只知道Minitest,没有Rspec)
require 'test_helper'
class PracticesIndexTest < ActionDispatch::IntegrationTest
test "select2 should work properly" do
get practices_path
assert_template 'practices/index'
assert_select 'select.multi_select', count: 2
get practice_path(id: 2)
# something like 'javascript:history.back()' ?
assert_select 'select.multi_select', count: 2
end
end
我对编程还很陌生(直接从Michael Hartls rails教程进入这个项目)。所以我希望你的专业人士可以帮助我;)THX