From 9471c3c574d12943524dc70f8b942d902f2d746e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 21 Jul 2015 15:43:47 +0200 Subject: [PATCH] js: Make use of the _frameUpload parameter when submitting a form.. ..to an iframe. This ensures that stuff like notifications are immediately visible to the user after successful form submission. refs #8758 --- public/js/icinga/loader.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 3a3e1a4bf..0af0863e3 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -151,20 +151,26 @@ var self = this; $form.prop('action', self.icinga.utils.addUrlParams(action, { - '_disableLayout': true + '_frameUpload': true })); $form.prop('target', 'fileupload-frame-target'); $('#fileupload-frame-target').on('load', function (event) { var $frame = $(event.target); + var $contents = $frame.contents(); - // Fetch the frame's new content, paste it into the target.. - self.renderContentToContainer( - $frame.contents().find('body').html(), - $target, - 'replace' - ); - $frame.prop('src', 'about:blank'); // ..and clear the frame's dom + var $redirectMeta = $contents.find('meta[name="redirectUrl"]'); + if ($redirectMeta.length) { + self.loadUrl($redirectMeta.attr('content'), $target); + } else { + // Fetch the frame's new content and paste it into the target + self.renderContentToContainer( + $contents.find('body').html(), + $target, + 'replace' + ); + } + $frame.prop('src', 'about:blank'); // Clear the frame's dom $frame.off('load'); // Unbind the event as it's set on demand }); },