parent
be88683c19
commit
37b87eb284
|
@ -269,6 +269,17 @@
|
||||||
url = icinga.utils.addUrlParams(url, dataObj);
|
url = icinga.utils.addUrlParams(url, dataObj);
|
||||||
} else {
|
} else {
|
||||||
if (encoding === 'multipart/form-data') {
|
if (encoding === 'multipart/form-data') {
|
||||||
|
if (typeof window.FormData === 'undefined') {
|
||||||
|
icinga.loader.submitFormToIframe($form, url, $target);
|
||||||
|
|
||||||
|
// Disable all form controls to prevent resubmission as early as possible.
|
||||||
|
// (This relies on native form submission, so using setTimeout is the only possible solution)
|
||||||
|
setTimeout(function () {
|
||||||
|
$form.find(':input:not(:disabled)').prop('disabled', true);
|
||||||
|
}, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
data = new window.FormData($form[0]);
|
data = new window.FormData($form[0]);
|
||||||
} else {
|
} else {
|
||||||
data = $form.serializeArray();
|
data = $form.serializeArray();
|
||||||
|
|
|
@ -140,6 +140,35 @@
|
||||||
return req;
|
return req;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mimic XHR form submission by using an iframe
|
||||||
|
*
|
||||||
|
* @param {object} $form The form being submitted
|
||||||
|
* @param {string} action The form's action URL
|
||||||
|
* @param {object} $target The target container
|
||||||
|
*/
|
||||||
|
submitFormToIframe: function ($form, action, $target) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
$form.prop('action', self.icinga.utils.addUrlParams(action, {
|
||||||
|
'_disableLayout': true
|
||||||
|
}));
|
||||||
|
$form.prop('target', 'fileupload-frame-target');
|
||||||
|
$('#fileupload-frame-target').on('load', function (event) {
|
||||||
|
var $frame = $(event.target);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
$frame.off('load'); // Unbind the event as it's set on demand
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an URL relative to the Icinga base Url, still unused
|
* Create an URL relative to the Icinga base Url, still unused
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue