From 029ae11ed56aaebf0864bbc6139d731f4cac1f19 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 19 Feb 2015 19:10:01 -0500 Subject: [PATCH] rewards - cleanup --- public/src/admin/extend/rewards.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/public/src/admin/extend/rewards.js b/public/src/admin/extend/rewards.js index 0bf6fa35d9..b73ad877b0 100644 --- a/public/src/admin/extend/rewards.js +++ b/public/src/admin/extend/rewards.js @@ -20,19 +20,24 @@ define('admin/extend/rewards', function() { }); $('.delete').on('click', function() { - var id = $(this).parents('[data-index]'); + var parent = $(this).parents('[data-index]'), + id = parent.attr('data-index'); delete active[id]; // send delete api call + + parent.remove(); + return false; }); $('.toggle').on('click', function() { var btn = $(this), disabled = btn.html() === 'Disabled', - id = $(this).parents('[data-index]'); + id = $(this).parents('[data-index]').attr('data-index'); btn.toggleClass('btn-warning').toggleClass('btn-success').html(disabled ? 'Enabled' : 'Disabled'); // send disable api call + return false; }); }); }; @@ -93,6 +98,10 @@ define('admin/extend/rewards', function() { div.html(html); + populateInputs(); + } + + function populateInputs() { $('[data-rewardID]').each(function(i) { var div = $(this).find('.inputs'), rewards = active[i].rewards;