wisemapping-frontend/packages/mindplot/test/playground/map-render/bootstrap/BootstrapDialog.Request.js

48 lines
1.5 KiB
JavaScript
Raw Normal View History

BootstrapDialog.Request = new Class({
Extends: BootstrapDialog,
2021-12-04 01:11:17 +01:00
initialize: function (url, title, options) {
this.parent(title, options);
this.requestOptions = {};
this.requestOptions.cache = false;
var me = this;
2021-12-04 01:11:17 +01:00
this.requestOptions.fail = function (xhr) {
// Intercept form requests ...
console.log("Failure:");
console.log(xhr);
};
2021-12-04 01:11:17 +01:00
this.requestOptions.success = function () {
// Intercept form requests ...
var forms = me._native.find('form');
2021-12-04 01:11:17 +01:00
_.each(forms, function (form) {
$(form).on('submit', function (event) {
// Intercept form ...
me.requestOptions.url = form.action;
me.requestOptions.method = form.method ? form.method : 'post';
$.ajax(me.requestOptions);
event.stopPropagation();
return false;
});
});
};
this._native.find('.modal-body').load(url, function () {
me.acceptButton.unbind('click').click(function () {
submitDialogForm();
});
me._native.on('hidden.bs.modal', function () {
$(this).remove();
});
me.show();
});
},
2021-12-04 01:11:17 +01:00
onDialogShown: function () {
if (typeof (onDialogShown) == "function") {
onDialogShown();
}
}
});