基本上,我試圖從軌道button_to得到下拉按鈕,這是通過ajax完成的,當有人點擊該按鈕時,它通過ajax渲染顯示呈現購物車<ul>
標記。rails button_to type =「button」
自舉:
<button class="btn btn-primary dropdown-toggle" type = "button" data-toggle="dropdown"><span class="glyphicon glyphicon-shopping-cart"></span> <span class="badge"><%="#{@cart.line_items_count}" %></span></button>
導軌button_to:
%= button_to navbar_cart_path, {remote :true, method: :get, :class => 'btn btn-primary dropdown-toggle', data_toggle: "dropdown"} do %>
<span class="glyphicon glyphicon-shopping-cart"></span>
<span class="badge" id="cart-badge-id"><%="#{@cart.line_items_count}" %></span>
<% end %>
看着HTML源代碼時,此產生類似的按鈕標籤,除了,引導按鈕具有屬性類型= 「按鈕」,但是軌道產生type =「submit」
bootstrap:
<button class="btn btn-primary dropdown-toggle" type = "button" data-toggle="dropdown"><span class="glyphicon glyphicon-shopping-cart"></span> <span class="badge">5</span></button>
個
導軌:
<form class="button_to" method="get" action="/navbar_cart data-remote="true">
<button class="btn btn-primary dropdown-toggle" data_toggle="dropdown" type="submit">
<span class="glyphicon glyphicon-shopping-cart"></span>
<span class="badge" id="cart-badge-id">5</span>
</button></form>
如果不論它甚至有可能甚至使一個下拉菜單,這種方式的另一個大問題。
不,我想使下拉菜單,我列出了我的購物車產品,圖片,數量等。 –