2016-07-06 66 views
1

我已經安裝了一個表格並設置了remote: true就可以了。雖然它工作,如果我直接刷新頁面。如果我從菜單導航到所需的形式,按鈕只是不做任何事情。表格與遠程:真正不與渦輪鏈接

我嘗試添加「數據沒有的TurboLink =」 true」以菜單的鏈接,但它仍然沒有也許5不知道?

<%= form_for :location, url: get_inventory_path, remote: true do |f| %> 
      <div class="input-field col s12"> 
       <%= f.select :location_id, options_for_select(@locations.collect { |l| 
       [l.station + ', ' + l.venue + ', ' + l.area + ', ' + l.city + ', ' + l.country, l.id] }, 1), {}, { id: 'location_select', class: "browser-default" } %> 
      </div> 
     </div> 
     </div> 
     <div class="card-action center-align"> 
     <%= f.submit "Go", class: "btn blue", data: { disable_with: "Please wait..." } %> 
     </div> 
     <% end %> 

我還添加了新的事件工作,因爲turbolinks的turbolinks 5的聽衆,這使得事情變得更容易,但話又說回來..

$(document).on('turbolinks:load',function(){ 
    $(".button-collapse").sideNav(); 
    $('select').material_select(); 
    $('.dropdown-button').dropdown({ 
    belowOrigin: true, 
    constrain_width: false, 
    alignment: "right" 
    }); 
    $('.collapsible').collapsible(); 
    $('.tooltipped').tooltip({delay: 50}); 
}); 

任何線索,歡迎!

+0

你剛剛升級到'turbolinks 2.5 - > 5.0'嗎?如果是這樣,在更新到5之前它工作正常嗎? – mrvncaragay

+0

不,這是一個全新的應用程序,我正在與最新的鋼軌版本... –

+0

一個建議嘗試'寶石jquery-turbolinks'如果你havnt嘗試過它 – mrvncaragay

回答

2

因此,似乎對某些元素禁用turbolinks工作,但因爲Turbol它改變墨水5,我錯過了turbolinks 5文檔。對於未來的參考文檔,從

<a href="/" data-turbolinks="false">Disabled</a> 

<div data-turbolinks="false"> 
    <a href="/">Disabled</a> 
</div> 

Rails的例子

<%= link_to "Overview", inventory_index_path, :"data-turbolinks"=>"false" %>

的例子,我希望這會有所幫助,但如果有人發現真正的問題不要讓我們大家都知道!

+1

更好:'<%= link_to「概覽」,inventory_index_path,data:{turbolinks:false}%>' – dft

-1

嘗試將所有js文件加載到頭部而不是在主體的末尾。

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title><%= content_for?(:title) ? yield(:title) : "app" %></title> 
    <%= csrf_meta_tags %> 
    <%= favicon_link_tag %> 
    <%= stylesheet_link_tag "application", :media => "all" %> 
    <%= javascript_include_tag "application" %> 
    </head> 
    <body> 
    <%= render "layouts/application_header" %> 
    <div class="container"> 
     <div class="row"> 
     <div class="col-lg-12"> 
      <%= yield %> 
     </div> 
     </div><!--/row--> 
    </body> 
</html> 

oy從現在開始你會有同樣的問題。

並添加寶石jquery turbolinks並按照說明那裏。 https://github.com/kossnocorp/jquery.turbolinks 然後你可以再次使用文檔準備在你的頁面

+0

實際上它在上面我沒有改變。 –

+0

我編輯了答案,請看看 – xploshioOn

+0

恐怕還是,jquery.turbolinks與turbolinks 5不兼容......問題出在表單上,​​跟我自己的javascript沒有關係,運行的很好。 –