# Agile web development with Rails - Issue with Depot app

**URL:** <https://www.ruby-forum.com/t/agile-web-development-with-rails-issue-with-depot-app/107882>\
**Category:** Rails\
**Created:** [June 27, 2007, 3:43am UTC](https://www.ruby-forum.com/t/agile-web-development-with-rails-issue-with-depot-app/107882 "2007-06-27T03:43:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 27, 2007, 3:43am UTC](https://www.ruby-forum.com/t/agile-web-development-with-rails-issue-with-depot-app/107882/1 "2007-06-27T03:43:30Z")

</div>

Hi

I"m trying to run through the sample Depot app while I learn all the  
little pieces of Rails and I came upon an error I’m intrigued by.

I am adding an Ajax hook into a page view and the content is rendered  
correctly (It’s the D2 - Ajax Based Cart section). The problem is, when  
I use the ‘add to cart’ button it adds the element but the HTML sent  
back by the Ajax call isn’t treated by the stylesheets (although all the  
data is intact, it’s just in black text / normal size), if I refresh the  
whole page it’s rendered fine.

I have basically ‘diffed’ the section of the cart being rendered and  
there is not a single thing wrong, hence why I suspect it’s how Firefox  
handle CSS applications post page processing.

Then again I see site using Ajax without this issue so I know it’s me  
and not Firefox. 🙂

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 27, 2007, 6:04am UTC](https://www.ruby-forum.com/t/agile-web-development-with-rails-issue-with-depot-app/107882/2 "2007-06-27T06:04:41Z")

</div>

OKay I"ll approach this from another angle.

I click to update my cart, works fine but renders the cart with no  
formatting. If I refresh the whole page the formatting is fine.

Now, if I click on the “add to cart” button AGAIN I get the following  
error:

RJS Error:  
TypeError element has no properties

I haven’t been able to find anything on the web that deals with this  
problem. (At nothing that has helped explain the issue and help me  
figure out the solution)

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 27, 2007, 6:18am UTC](https://www.ruby-forum.com/t/agile-web-development-with-rails-issue-with-depot-app/107882/3 "2007-06-27T06:18:13Z")

</div>

You are in IE right? Try firefox. This sounds like an IE problem I  
ran into a while back. Failing that, use FireBug under firefox to  
verify the response to the AJAX call is what you think it is, and the  
CSS class or properties are being set. If you are relying on some  
javascript to post-process the HTML to add CSS tags (as DOJO does),  
then this may not be processing the updated HTML.

Michael

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 27, 2007, 6:44am UTC](https://www.ruby-forum.com/t/agile-web-development-with-rails-issue-with-depot-app/107882/4 "2007-06-27T06:44:11Z")

</div>

Michael L. wrote:

> You are in IE right? Try firefox. This sounds like an IE problem I  
> ran into a while back. Failing that, use FireBug under firefox to  
> verify the response to the AJAX call is what you think it is, and the  
> CSS class or properties are being set. If you are relying on some  
> javascript to post-process the HTML to add CSS tags (as DOJO does),  
> then this may not be processing the updated HTML.
> 
> Michael

Firebug rocks thanks!

Okay The problem was a Code 13 (13" from the Monitor). Basically what  
set me off the whole time is the fact that rendering on reload, and not  
when I hit the Ajax button, worked. This told me something was missing  
that tells the browser what style to apply.

Digging into the code being displayed (with Firebug), I notice it’s all  
wrapped around a DIV Tag, but when I hit my submit button it’s not there  
anymore.

The reason was this:

I had:  
page.replace( “cart”, :partial =\> “cart”, :object =\> @cart )

I should have had:  
page.replace\_html( “cart”, :partial =\> “cart”, :object =\> @cart )

The replace method was replacing the WHOLE div not just the ‘inner html’  
portion of it. Thus the first process was submitting properly (but not  
rendering because it had no class ID) and the second, and subsequent  
submits, were missing an ID so the Ajax couldn’t find it to ‘refresh’  
it’s state…

I.E. The RJS template couldn’t find the “cart” element to update:

Love this forum. Always points me in the right direction IF doesn’t  
answer the problem directly. 🙂

Thanks Mike. (I hope you don’t mind being called Mike)
