2016-11-10 221 views
0

我用我的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

同樣的問題。通過去除Turbolinks修復。

刪除

寶石 「turbolinks」

從您的Gemfile和運行捆綁

刪除

// =需要turbolinks

從application.js中