From 8677d96ed8a37ec6d441904c841542beab62558c Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 8 Aug 2016 16:33:47 +0100 Subject: [PATCH] Modified the episode modal so that we are now resetting the button after a request --- PlexRequests.UI/Content/search.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/PlexRequests.UI/Content/search.js b/PlexRequests.UI/Content/search.js index 0c562738a..05cf526e4 100644 --- a/PlexRequests.UI/Content/search.js +++ b/PlexRequests.UI/Content/search.js @@ -576,15 +576,12 @@ $(function () { // Save Modal click $("#episodesRequest").click(function (e) { e.preventDefault(); - + var origHtml = $('#episodesRequest').html(); var tvId = $('#selectedEpisodeId').val(); - $("#episodesRequest").prop("disabled", true); loadingButton("episodesRequest", "primary"); - - + var $form = $('#form' + tvId); - var model = []; var $checkedEpisodes = $('.selectedEpisodes:checkbox:checked'); @@ -601,10 +598,28 @@ $(function () { Episodes: model } - var url = createBaseUrl(mainBaseUrl, "search/request/tvEpisodes"); - var type = $form.prop('method'); + var methodUrl = createBaseUrl(mainBaseUrl, "search/request/tvEpisodes"); + var methodType = $form.prop('method'); $('#episodesModal').modal('toggle'); - sendRequestAjax(JSON.stringify(finalObj), type, url, tvId); + + $.ajax({ + type: methodType, + url: methodUrl, + data: JSON.stringify(finalObj), + dataType: "json", + success: function (response) { + finishLoading("episodesRequest", "primary", origHtml); + if (response.result === true) { + generateNotify(response.message); + } else { + generateNotify(response.message, "warning"); + } + }, + error: function(e) { + console.log(e); + generateNotify("Something went wrong!", "danger"); + } + }); }); function buildSeasonsContext(result) {