small medium large xlarge

Generic-user-small
17 Oct 2009, 14:00
Zeeshan Ansari (8 posts)

i m using rails 2.3.3 and web browser Firefox i have added ajax and java script and it is working too but i have to reload the page every time when i press Add to Cart button to show item additionn in the side bar it don’t show it without reloading.

anyone please help me how can it show item addition in side bar when i press Add to Cart button with out reloading the page?

Generic-user-small
18 Oct 2009, 15:17
Zeeshan Ansari (8 posts)

why don’t ppl reply to questions?

Generic-user-small
25 Oct 2009, 23:03
Dimitri De Frenne (2 posts)

I don’t have an answer to your problem, but I think mine is related. The Ajax-part itself works without a problem. The problems start when I add the Highlight (Iteration D3). The highlight works the first time I press the “Add to cart”-button. Pressing it again (or another “Add to cart”-button for that matter) changes nothing. It’s still as if only 1 thing has been added to the cart. Reloading the page shows that the 2nd item has been added too.

When checking the output from Mongrel I get this: ` ActionView::TemplateError (You have a nil object when you didn’t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[]) on line #1 of app/views/store/_cart_item.html.erb: 1: <% if cart_item == @current_item %> 2: <tr id="current_item"> 3: <% else %> 4: <tr>

app/views/store/_cart_item.html.erb:1
app/views/store/_cart.html.erb:3
app/views/store/add_to_cart.js.rjs:1:in `_run_rjs_app47views47store47add_to_cart46js46rjs'
app/views/store/add_to_cart.js.rjs:1:in `_run_rjs_app47views47store47add_to_cart46js46rjs'
app/controllers/store_controller.rb:10:in `add_to_cart'

Rendered rescues/_trace (67.5ms) Rendered rescues/_request_and_response (0.3ms) Rendering rescues/layout (internal_server_error) `

I’ve checked all my code and it’s the same as in the book or as in the files online and it works the first time so I have no idea what’s causing it.

btw: I’ve got Rails 2.3.4

You must be logged in to comment