X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f59e7c3de6bd0f85a61a4d9481db60cd7369ae92..b07520a11332374de645ed22c74959afa8a4b7ed:/wolnelektury/static/js/dialogs.js 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();