Add support for modal dialog multiple request.

This commit is contained in:
Paulo Veiga
2011-10-17 10:12:27 -03:00
parent 0133f127b8
commit 8913b5f187
7 changed files with 131 additions and 121 deletions

View File

@@ -15,17 +15,47 @@ MooDialog.Request = new Class({
initialize: function(url, requestOptions, options) {
this.parent(options);
this.requestOptions = requestOptions || {method:'get'};
this.requestOptions.url = url;
this.requestOptions = requestOptions || {};
this.requestOptions.update = this.content;
this.requestOptions.evalScripts = true;
this.requestOptions.noCache = true;
this.requestOptions.onFailure = function(xhr) {
// Intercept form requests ...
console.log("Failure:");
console.log(xhr);
}.bind(this);
this.requestOptions.onSuccess = function() {
// Intercept form requests ...
var forms = this.content.getElements('form');
forms.forEach(function(form) {
form.addEvent('submit', function(event) {
// Intercept form ...
this.requestOptions.url = form.action;
this.requestOptions.method = form.method ? form.method : 'post';
var request = new Request.HTML(this.requestOptions);
request.post(form);
event.stopPropagation();
return false;
}.bind(this))
}.bind(this));
}.bind(this);
this.addEvent('open', function() {
var request = new Request.HTML(this.requestOptions).send();
this.requestOptions.url = url;
this.requestOptions.method = 'get';
var request = new Request.HTML(this.requestOptions);
request.send();
MooDialog.Request.active = this;
}.bind(this));
if (this.options.autoOpen) this.open();
this.addEvent('close', function() {
MooDialog.Request.active = null;
}.bind(this));
if (this.options.autoOpen) this.open();
},
setRequestOptions: function(options) {