2021-12-02 01:41:56 +01:00
|
|
|
BootstrapDialog.Request = new Class({
|
|
|
|
Extends: BootstrapDialog,
|
2021-12-04 01:11:17 +01:00
|
|
|
initialize: function (url, title, options) {
|
2021-12-02 01:41:56 +01:00
|
|
|
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) {
|
2021-12-02 01:41:56 +01:00
|
|
|
// Intercept form requests ...
|
|
|
|
console.log("Failure:");
|
|
|
|
console.log(xhr);
|
|
|
|
};
|
|
|
|
|
2021-12-04 01:11:17 +01:00
|
|
|
this.requestOptions.success = function () {
|
2021-12-02 01:41:56 +01:00
|
|
|
// 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) {
|
2021-12-02 01:41:56 +01:00
|
|
|
// 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") {
|
2021-12-02 01:41:56 +01:00
|
|
|
onDialogShown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|