X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6cc5df1faff7c600d0cf4b4174621eca99e86354..d60f44f5eceafa25705d55044ae1b11aceb28187:/wolnelektury/static/js/dialogs.js?ds=sidebyside diff --git a/wolnelektury/static/js/dialogs.js b/wolnelektury/static/js/dialogs.js index 0793a7ffd..bf9d94b54 100755 --- a/wolnelektury/static/js/dialogs.js +++ b/wolnelektury/static/js/dialogs.js @@ -27,14 +27,22 @@ hash.w.show(); }, onLoad: function(hash) { - $('form', hash.w).each(function() {this.action += '?ajax=1';}); + $('form', hash.w).each(function() { + if (this.action.search('[\\?&]ajax=1') != -1) + return; + if (this.action.search('\\?') != -1) + this.action += '&ajax=1'; + else this.action += '?ajax=1'; + }); $('form', hash.w).ajaxForm({ dataType: 'json', target: $('.target', $window), success: function(response) { if (response.success) { $('.target', $window).text(response.message); - setTimeout(function() { $window.jqmHide() }, 1000) + setTimeout(function() { $window.jqmHide() }, 1000); + if (response.redirect) + window.location = response.redirect; } else { $('.error', $window).remove();