I have a series of objects that have a link inside to toggle a swap. The "next" swap algorithm appends the current object to the next object.
$('a.getNext').click(function() {
var selector = 'div.foo';
var currentObject = $(this).parents(selector).first();
var nextObject = currentObject.nextAll(selector).first();
nextObject.append(currentObject);
});
The swap happens but the link that invoked the swapping (in the "current" context) no longer works. Watching the debugger, after clicking the link again and seeing what object currentObject
appears to be, it's empty whitespace in the browser. How can I reestablish the connection between the click()
target and the correct "new"(?) foo
div it lives inside?
Here's a working example: http://jsfiddle.net/Z863z/2/