From adc784718ded2dc5282985c64b1a80b210ca5873 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 12 Mar 2018 21:53:45 -0400 Subject: [PATCH] Unwanted page reload when doing an ajax call using the search bar --- views/episodes.tpl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/views/episodes.tpl b/views/episodes.tpl index 969c02bbb..1bbe06465 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -70,10 +70,6 @@ var first_season_acc_content = document.getElementsByClassName("content")[0]; first_season_acc_content.className += " active"; }); - - $(window).on('beforeunload',function(){ - $('#loader').addClass('active'); - }); @@ -288,7 +284,12 @@ dataType: "json", data: values }); - $('#loader').addClass('active'); + $(document).ajaxStart(function(){ + $('#loader').addClass('active'); + }); + $(document).ajaxStop(function(){ + window.location.reload(); + }); }) $('.get_subtitle').click(function(){ @@ -307,12 +308,17 @@ dataType: "json", data: values }); - $('#loader').addClass('active'); + $(document).ajaxStart(function(){ + $('#loader').addClass('active'); + }); + $(document).ajaxStop(function(){ + window.location.reload(); + }); }) - $(document).ajaxStop(function(){ - window.location.reload(); - }); + $('a, i').click(function(){ + $('#loader').addClass('active'); + }) $('.modal') .modal({