From 637db8580d4acac338f1c842623e35c65d1f62c8 Mon Sep 17 00:00:00 2001 From: skullbocks Date: Wed, 20 Aug 2014 21:13:16 +0200 Subject: [PATCH] [WebUI #7] Fixing functions to add and delete elements --- assets/public/js/functions_script.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/assets/public/js/functions_script.js b/assets/public/js/functions_script.js index eba546d..e4f5d7c 100644 --- a/assets/public/js/functions_script.js +++ b/assets/public/js/functions_script.js @@ -14,11 +14,16 @@ window.location.href = $(this).attr("data-post"); }); $body.on('click', '.delete-row', function() { - $.post("/admin/delete_" + $(this).attr("data-type") + "/" + $(this).parent().parent().attr("id"), function(data) { - if (data == 1) { - $(this).parent().parent().hide("fast").remove(); + var $thisButton = $(this); + console.log($thisButton.parent().parent()); + $.post("/admin/delete_" + $thisButton.attr("data-type") + "/" + $thisButton.parent().parent().attr("id"), function(data) { + if (data.result == 1) { + $thisButton.parent().parent().hide("fast").remove(); + if ($thisButton.hasClass('.popover-remove-row')){ + $(".popover-gpio-"+$thisButton.attr("data-type")).find('tr#'+$thisButton.parent().parent().attr("id")).remove(); + } } - }); + }, 'json'); }); $gpioPopover.popover({ html: true,