我正在开发一个电子商务网站..现在我陷入了困境......当我提交表单时,它没有提交第一次点击,我需要给第二次点击让它工作......我用锚标签提交我的数据bcoz我想在thickbox(iframe)里面显示数据...
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
我已经在firebug和populate方法中看到了处理,但它没有将数据发送到购物车,它显示我空车...并且购物车正在处理......
答案 0 :(得分:0)
您正在发送 ajax请求,从表单中删除:remote => true
选项并进行检查。