NOTE: This post is now obsolete. I more carefully read Mitchell’s post above and tried Prototype’s Ajax.Updater. WORKS! Thanks, MK!
mdesign - 18 December 2007 10:18 PM
Bill, thanks a ton for sharing. Just noting that the particular code Bill shared only works on a unique UL/LI. If you have 3 or 4 LI’s and you click to remove one, the message will show up for all LI’s in the UL. You would need to get the parent item of the one you clicked and replace (or load) the results of the get into that.
So… I’ve been beating my brains out trying to do just this.
I can get this stuff to work as advertised within a UL/LI structure, but the duplicate messages appear in all the LI’s. Plus, a UL/LI structure doesn’t work for me design-wise, as I need to put more than one kind of link on the Save to Favorites line.
So I’ve tried to use spans (divs are too problematic side-by-side), and the basic theory I’ve been working on is that by adding an ID to the link tag and a matching class attribute to the surrounding span (or whatever the parent might be), I could identify the parent node without having to use target or srcElement. Each of these identifying attributes contains something like “favespan” plus the {entry_id} for uniqueness.
Getting the class and id injected is easy. Addressing them is giving me gas—but that’s expected, since my Javascript skills are… well… not really skills. Here’s a bit of what I’m doing:
$().ready(function() {
$('a.Favorites_Trigger') .click (function(e) {
$.get(this.href, function(data) {
var linkSpan = e.target.id;
$('span.'.linkSpan).html(data);
});
return false;
});
});
With the HTML being something like:
<span class="favespan{entry_id}">
<a class="Favorites_Trigger" id="favespan{entry_id}" href="{path='favorites/add_favorite/'}{entry_id}">Save to Faves</a>
</span>
The variable linkSpan is being correctly filled with something like “favespan21”, so it looks like the next line of the js is where the problem is. I’m not concatenating properly, or…?
I’m sure it’s something simple. It always is with me. 
Thanks!