BootstrapDialog.Request implementation

This commit is contained in:
Ezequiel Bergamaschi 2014-09-01 02:45:15 -03:00
parent 094d08df4d
commit 2459a14c9b
3 changed files with 51 additions and 0 deletions

View File

@ -53,6 +53,7 @@
<include>${basedir}/target/tmp/Utils-min.js</include>
<include>${basedir}/../mindplot/src/main/javascript/Options.js</include>
<include>${basedir}/../mindplot/src/main/javascript/libraries/bootstrap/BootstrapDialog.js</include>
<include>${basedir}/../mindplot/src/main/javascript/libraries/bootstrap/BootstrapDialog.Request.js</include>
</includes>
</aggregation>
</aggregations>

View File

@ -0,0 +1,49 @@
BootstrapDialog.Request = new Class({
Extends: BootstrapDialog,
initialize: function(url, requestOptions, options) {
//this.parent(options);
this.requestOptions = requestOptions || {};
this.requestOptions.cache = false;
var me = this;
this.requestOptions.fail = function(xhr) {
// Intercept form requests ...
console.log("Failure:");
console.log(xhr);
};
this.requestOptions.success = function() {
// Intercept form requests ...
var forms = me._native.find('form');
_.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;
});
});
};
var request = $('<div></div>');
request.load(url, function() {
me._native = $(this).find('.modal');
if (!me._native) {
throw new Error('modal not found');
} else {
$(document.body).append(me._native);
me.show();
}
});
this._native.on('hidden.bs.modal', function () {
$(this).remove();
});
}
});

View File

@ -130,4 +130,5 @@ div#headerActions a:hover, div#headerActions a:active, div#headerActions a:link,
#dialogMainForm label
{
font-weight:normal;
display: block;
}