2015-05-11 24 views
0

我有以下購物車視圖,我用引導addapted。如何修改大禮包商務購物車中的輸入值

<div class="row line_item"> 

    <div class="col-md-4 cart-item-image" data-hook="cart_item_image"> 
     <% if variant.images.length == 0 %> 
     <%= link_to small_image(variant.product), variant.product %> 
     <% else %> 
     <%= link_to image_tag(variant.images.first.attachment.url(:product)), variant.product %> 
     <% end %> 
    </div> 
    <div class="col-md-4 cart-item-image" data-hook="cart_item_description"> 
     <h4><%= link_to line_item.name, product_path(variant.product) %></h4> 
     <%= variant.options_text %> 
     <% if line_item.insufficient_stock? %> 
     <span class="out-of-stock"> 
      <%= Spree.t(:out_of_stock) %>&nbsp;&nbsp;<br /> 
     </span> 
     <% end %> 
     <span class="line-item-description" data-hook="line_item_description"> 
     <%= line_item_description_text(line_item.description) %> 
     </span> 
    </div> 
    <div class="col-md-1 cart-item-price" data-hook="cart_item_price"> 
     <%= line_item.single_money.to_html %> 
    </div> 
    <div class="col-md-1 cart-item-quantity" data-hook="cart_item_quantity" valign="center"> 
     <%= item_form.number_field :quantity, min: 0, class: "form-control line_item_quantity", size: 5 %> 
    </div> 
    <div class="col-md-2"> 
     <div class="cart-item-total" data-hook="cart_item_total"> 
     <%= line_item.display_amount.to_html unless line_item.quantity.nil? %> 
     </div> 
     <div class="cart-item-delete" data-hook="cart_item_delete"> 
     <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-minus-sign'), '#', class: 'delete', id: "delete_#{dom_id(line_item)}" %> 
     </div> 
    </div> 
    </div> 

及以下的CoffeeScript與它

Spree.ready ($) -> 
    if ($ 'form#update-cart').is('*') 
    ($ 'form#update-cart a.delete').show().one 'click', -> 
     ($ this).parents('.line-item').first().find('input.line_item_quantity').val 0 
     ($ this).parents('form').first().submit() 
     false 

    ($ 'form#update-cart').submit -> 
    ($ 'form#update-cart #update-button').attr('disabled', true) 

現在刪除按鈕不使用此車的HTML工作(雖然它正在與下面的原始視圖)

<div style="margin-top: 35px;"> 
    <div class="row"> 
    <tr class="line-item"> 
    <td class="col-md-4 cart-item-image" data-hook="cart_item_image"> 
     <% if variant.images.length == 0 %> 
     <%= link_to small_image(variant.product), variant.product %> 
     <% else %> 
     <%= link_to image_tag(variant.images.first.attachment.url(:small)), variant.product %> 
     <% end %> 
    </td> 
    <td class="col-md-4 cart-item-description" data-hook="cart_item_description"> 
     <h4><%= link_to line_item.name, product_path(variant.product) %></h4> 
     <%= variant.options_text %> 
     <% if line_item.insufficient_stock? %> 
     <span class="out-of-stock"> 
      <%= Spree.t(:out_of_stock) %>&nbsp;&nbsp;<br /> 
     </span> 
     <% end %> 
     <span class="line-item-description" data-hook="line_item_description"> 
     <%= line_item_description_text(line_item.description) %> 
     </span> 
    </td> 
    <td class="col-md-1 lead text-primary cart-item-price" data-hook="cart_item_price"> 
     <%= line_item.single_money.to_html %> 
    </td> 
    <td class="col-md-1 cart-item-quantity" data-hook="cart_item_quantity" valign="center"> 
     <%= item_form.number_field :quantity, min: 0, class: "form-control line_item_quantity", size: 5 %> 
    </td> 
    <td class="col-md-1 lead text-primary cart-item-total" data-hook="cart_item_total"> 
     <%= line_item.display_amount.to_html unless line_item.quantity.nil? %> 
    </td> 
    <td class="col-md-1 cart-item-delete" data-hook="cart_item_delete"> 
     <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-minus-sign'), '#', class: 'delete', id: "delete_#{dom_id(line_item)}" %> 
    </td> 
    </tr> 
</div> 
</div> 
一起去

在我看來,咖啡標記應該在兩種情況下工作!

我在修改視圖後錯過了什麼?在我看來,咖啡腳本應該在這兩種情況下執行搜索...

回答

0

它看起來不像你做錯了什麼,當保持JavaScript的標記相同。我的猜測是Spree.ready ($) ->實際上並沒有發射。這可能是由於您在視圖定製過程中意外刪除了JavaScript文件導致的。你應該嘗試檢查你的Web開發者控制檯,看看是否有像Spree一樣的JavaScript錯誤沒有被定義或類似的東西。