diff --git a/RequestPlex.UI/Content/requests.js b/RequestPlex.UI/Content/requests.js index 5a08e0319..2519696e3 100644 --- a/RequestPlex.UI/Content/requests.js +++ b/RequestPlex.UI/Content/requests.js @@ -28,7 +28,7 @@ $(document).on("click", ".delete", function (e) { if (response.result === true) { generateNotify("Success!", "success"); - $("#" + buttonId + "Template").html(""); + $("#" + buttonId + "Template").slideUp(); } else { generateNotify(response.message, "warning"); } diff --git a/RequestPlex.UI/Content/search.js b/RequestPlex.UI/Content/search.js index ba4591eca..868240c76 100644 --- a/RequestPlex.UI/Content/search.js +++ b/RequestPlex.UI/Content/search.js @@ -35,29 +35,10 @@ $(document).on("click", ".dropdownTv", function (e) { data = data + "&latest=true"; } - $.ajax({ - type: $form.prop('method'), - url: $form.prop('action'), - data: data, - dataType: "json", - success: function (response) { - console.log(response); - if (response.result === true) { - generateNotify("Success!", "success"); - - $('#' + buttonId).html(" Requested "); - $('#' + buttonId).removeClass("btn-primary"); - $('#' + buttonId).addClass("btn-success"); - } else { - generateNotify(response.message, "warning"); - } - }, - error: function (e) { - console.log(e); - generateNotify("Something went wrong!", "danger"); - } - }); + var type = $form.prop('method'); + var url = $form.prop('action'); + sendRequestAjax(data, type, url, buttonId); }); // Click Request for movie @@ -66,10 +47,18 @@ $(document).on("click", ".requestMovie", function (e) { var buttonId = e.target.id; var $form = $('#form' + buttonId); + var type = $form.prop('method'); + var url = $form.prop('action'); + var data = $form.serialize(); + + sendRequestAjax(data, type, url, buttonId); +}); + +function sendRequestAjax(data, type, url, buttonId) { $.ajax({ - type: $form.prop('method'), - url: $form.prop('action'), - data: $form.serialize(), + type: type, + url: url, + data: data, dataType: "json", success: function (response) { console.log(response); @@ -78,6 +67,7 @@ $(document).on("click", ".requestMovie", function (e) { $('#' + buttonId).html(" Requested"); $('#' + buttonId).removeClass("btn-primary"); + $('#' + buttonId).removeAttr("data-toggle"); $('#' + buttonId).addClass("btn-success"); } else { generateNotify(response.message, "warning"); @@ -88,9 +78,7 @@ $(document).on("click", ".requestMovie", function (e) { generateNotify("Something went wrong!", "danger"); } }); - -}); - +} function movieSearch() { $("#movieList").html(""); diff --git a/RequestPlex.UI/Views/Search/Index.cshtml b/RequestPlex.UI/Views/Search/Index.cshtml index f687330c7..7014fbe66 100644 --- a/RequestPlex.UI/Views/Search/Index.cshtml +++ b/RequestPlex.UI/Views/Search/Index.cshtml @@ -68,7 +68,7 @@ {{/if_eq}} {{#if_eq type "tv"}}