On 10 August 2012 09:48, rubyrails9 <[email protected]> wrote:
> I am developing an e-commerce site.. and now I got stuck at one point.. When
> I submit the form ,it doesn't submits on the first click, and i need to give
> a second click to get it working... I have used anchor tag to submit my data
> bcoz I want to show the data inside 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
>
> I have seen in firebug and populate method is processed but it not sending
> data into cart and it showing me empty cart..and cart is processing...
>

Have a look in development.log and see what is added when you click it
the first time.  You will see what action, if any, is run.  Then have
a look at the Rails Guide on Debugging to see methods that are useful
for debugging the code.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to