var $j = jQuery.noConflict(); $j(document).ready(function() { $j(".add-wishlist").each(function (index, element) { $j(element).click(function() { var span = $j(element).find("span"); var gb_id = span.attr('id') if (!gb_id) return; jQuery.post('/wishlist/', {'googlebooks_id': gb_id}, function(data) { span.fadeOut(); var newSpan = $j('On Wishlist!').hide(); span.replaceWith(newSpan); newSpan.fadeIn('slow'); newSpan.removeAttr("id"); }); }); }); $j(".remove-wishlist").each(function (index, element) { $j(element).click(function() { var span = $j(element).find("span"); var work_id = span.attr('id') jQuery.post('/wishlist/', {'remove_work_id': work_id}, function(data) { var book = $j(element).closest('.thewholebook'); book.fadeOut(); }); }); }); $j(".create-account").each(function (index, element) { $j(element).click(function() { var span = $j(element).find("span"); var work_url = span.attr('title') window.location = "/accounts/login/?next=" + work_url; }); }); // in panel view on the supporter page we want to remove the entire book listing from view upon wishlist-remove // but on the work page, we only want to toggle the add/remove functionality // so: slightly different versions ahoy // note also that we don't have the Django ORM here so we can't readily get from work.id to googlebooks_id // we're going to have to tell /wishlist/ that we're feeding it a different identifier $j(".remove-wishlist-workpage").each(function (index, element) { $j(element).click(function() { var span = $j(element).find("span"); var work_id = span.attr('id') jQuery.post('/wishlist/', {'remove_work_id': work_id}, function(data) { span.parent().fadeOut(); var newDiv = $j('