I’m new to Ajax and am trying to get a basic app working as a vehicle
for learning it. The app is an extension of the cookbook tutorial. My
intent is to be able to add a list of ingredients for a recipe. The
page to add ingredients uses Ajax. As ingredients are added to the page
they’re displayed in a “green-bar” format like that used in the Depot
Ingredients are added to the page using form_remote_tag to update a
The stage I’m at now is that, when an item is removed from the page, it
messes up the green-bar effect. So I need to iterate through the
I’ve got the change to class working (thanks to help from Ed Frederick)
on a single item with:
page << “$(item3).className = ‘Listline1’;”
(In figuring this out, I’m entering 3 items, deleting the 2nd, then
changing the class of item3 which is now 2nd in the list)
So now I to figure out how to iterate through the remaining items,
either by starting at the top or working from the deletion point down.
In either case, I need to anticipate that this might not be the first /
only deletion and that there will be gaps in the item numbering
sequence. So I need to test for an item’s existence before I pipe the
line above (with the appropriate substitutions for ListlineY) into the
Is there a simple existence test? I’m hoping for something like if
Am I on the right track here?
Thanks in advance for any assistance / advice. Advice on a good book to
put me on track would be especially appreciated!