我正在使用Rails 4向导中的Bootstrap-slider gem,出于某种原因,当我使用滑块导航到向导步骤时,它会显示正确数量的滑块,但是一旦我明确指向下一步,然后回到滑块的步骤,加载两倍。
查看:
<div class="form-group col-sm-6">
<%= f.input :weightloss_desire, input_html: { data:
{provide: "slider",
"slider-max": 10,
"slider-min": 0,
"slider-step": 1,
"slider-tooltip": "hide",
"slider-ticks": [1,10],
"slider-ticks_positions": [0, 100],
"slider-ticks_labels": ["Minimal", "Strong!"],
"slider-tooltip": "hide",
"slider-value": @remote.weightloss_desire}
}, label_html: {class:"block"}, label: "Weight loss desire" %>
</div>
<div class="form-group col-sm-6">
<%= f.input :daily_stress, input_html: { data:
{provide: "slider",
"slider-max": 10,
"slider-min": 0,
"slider-step": 1,
"slider-tooltip": "hide",
"slider-ticks": [1,10],
"slider-ticks_positions": [0, 100],
"slider-ticks_labels": ["Minimal", "Strong!"],
"slider-tooltip": "hide",
"slider-value": @remote.daily_stress}
}, label_html: {class:"block"}, label: "Daily stress level" %>
</div>
刷新页面后,视图将恢复,仅显示2个滑块。此外,我不确定这是否相关,但我一直看到警告
bootstrap-slider.min.js:4 bootstrap-slider.js - WARNING: $.fn.slider namespace is already bound. Use the $.fn.bootstrapSlider namespace instead.
但由于我只调用内联滑块,我不确定如何纠正
答案 0 :(得分:0)
同样的问题。通过删除Turbolinks修复。
删除
从您的Gemfilegem“turbolinks”
运行包
删除
// =需要turbolinks
来自application.js