Merge pull request #2 from Gluejar/fix_wishlist_js

adding functionality erroneously removed, plus updating to use recent jq...[#35857177]
pull/1/head
eshellman 2012-09-14 07:07:17 -07:00
commit a3390b88bb
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");
});
});