HAML and Ajax in Lists

Hi! I have decided to go ahead with HAML and in some ways it feels
and in others I feel I am missing something important. Here’s my
question du

I have a list of catalog items each of which people can add to a cart.
they add an item, I want a little snippet below the item image to update
count of that item. E.g. (7 pairs of these shoes in your cart). I’m
link_to_remote and rjs to update, but it requires that I have
programmatically named DOM elements. Such as:


I don’t see how to explain to HAML that I want to specify the id at

%item{:id => ???}

doesn’t give me an opportunity to evaluate an expression as the list
item is
being evaluated. How are others solving this problem?


View this message in context:
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

This should work:

%item{:id => “item#{counter}”}

I’m using something like this:
%tr.{:class => “#{even_odd(counter)}”}

for even-odd class names for table rows.

Sorry for the tardy reply. I didn’t see this post.

We have implemented RJS style “simplyhelpful” helpers with dom-element
naming. Check out the README file (almost a tutorial) to see all of the
stuff you can do with HAML.


Assuming item is of class Item and id=32, then that would print

I’m actually confused by your comment that you can’t evaluate the
attributes { } during run time. They absolutely are evaluated at
runtime. You are free to do #item{:id => @item.id}… we are just
providing a helper with [] to doing that and use rails-standard naming