adding functionality erroneously removed, plus updating to use recent jquery function

pull/1/head
Andromeda Yelton 2012-09-14 09:21:05 -04:00
parent d4309dd46c
commit 6a2efa9c68
1 changed files with 17 additions and 1 deletions

View File

@ -55,7 +55,7 @@ $j().ready(function() {
// we're going to have to tell /wishlist/ that we're feeding it a different identifier
contentblock.on("click", "div.remove-wishlist-workpage", function () {
var span = $j(this).find("span");
var work_id = span.attr('id').substring(1)
var work_id = span.attr('id').substring(1);
// provide feedback
span.html('Removing...');
@ -70,3 +70,19 @@ $j().ready(function() {
});
});
});
var $k = jQuery.noConflict();
// allows user to re-add on work page after erroneously removing, without page reload
// can't bind this to document ready because the .add-wishlist-workpage div doesn't exist until remove-wishlist is executed
$k(document).on("click", ".add-wishlist-workpage span", function() {
var span = $k(this);
var work_id = span.attr("class");
if (!work_id) return;
jQuery.post('/wishlist/', {'add_work_id': work_id}, function(data) {
span.fadeOut();
var newSpan = $k('<span class="on-wishlist">On Wishlist!</span>').hide();
span.replaceWith(newSpan);
newSpan.fadeIn('slow');
newSpan.removeAttr("id");
});
});