0
我正在開發一個電子商務網站..現在我被卡住了一點..當我提交表單時,它不提交第一次點擊 ,我需要給第二點擊得到它的工作...我用錨標記提交我的數據bcoz我想展示裏面ThickBox的(IFRAME)數據...
submit()第一次在rails中不工作
View file
<%= form_for :order, :url => populate_orders_url ,:html => { :class => "data# product.id}"},:method => "post",:remote => true do |f| %>
// data
//submit button
<a href="/cart?KeepThis=true&TB_iframe=true&height=380&width=1000&modal=false" onclick="$('.data<%= product.id %>').submit().trigger.reload();" class="thickbox cart_button"></a>
orders controller.rb
def populate
@order = current_order(true)
params[:products].each do |product_id,variant_id|
quantity = params[:quantity].to_i if !params[:quantity].is_a?(Hash)
quantity = params[:quantity][variant_id].to_i if params[:quantity].is_a?(Hash)
@order.add_variant(Variant.find(variant_id), quantity, ad_hoc_option_value_ids, product_customizations) if quantity > 0
end if params[:products]
params[:variants].each do |variant_id, quantity|
quantity = quantity.to_i
@order.add_variant(Variant.find(variant_id), quantity, ad_hoc_option_value_ids, product_customizations) if quantity > 0
end if params[:variants]
fire_event('spree.cart.add')
fire_event('spree.order.contents_changed')
redirect_to cart
end
我有在螢火蟲和填充方法中看到處理,但它沒有發送數據到購物車,它顯示我空的cart..and購物車正在處理...
是的我知道,但如果我刪除它,購物車頁面將無法在thickbox中打開.....我想在thickbox中打開它。 – rank 2012-08-10 10:28:48
redirect_to無法按照我對ajax請求的瞭解,必須使用javascript窗口渲染一些js和'ajax:success'重定向到購物車頁面或者寫一些適當的js。 – Amar 2012-08-11 11:32:42