This will update multiple receivers with a single ajax call (Ajax.Updater)
Ajax.Updater(['element1','Element2','ElementN'],url,{method: 'GET'});
--- prototype.js 2006-01-20 20:09:28.000000000 +0000
+++ prototype.jsmuscle.js 2006-03-08 01:31:10.000000000 +0000
@@ -743,11 +743,18 @@
Ajax.Updater = Class.create();
Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
- initialize: function(container, url, options) {
+ initialize: function(containerArray, url, options) {
+
+ var success = failure = new Array();
+ containerArray.each(function(el){
+ success.push(el.success ? $(el.success) : $(el));
+ failure.push(el.failure ? $(el.failure) :
+ (el.success ? null : $(el)));
+ });
+
this.containers = {
- success: container.success ? $(container.success) : $(container),
- failure: container.failure ? $(container.failure) :
- (container.success ? null : $(container))
+ success: success,
+ failure: failure
}
this.transport = Ajax.getTransport();
@@ -763,18 +770,18 @@
},
updateContent: function() {
- var receiver = this.responseIsSuccess() ?
+ var receivers = this.responseIsSuccess() ?
this.containers.success : this.containers.failure;
var response = this.transport.responseText;
if (!this.options.evalScripts)
response = response.stripScripts();
- if (receiver) {
+ if (receivers) {
if (this.options.insertion) {
- new this.options.insertion(receiver, response);
+ receivers.each(function(receiver){ new this.options.insertion(receiver, response); });
} else {
- Element.update(receiver, response);
+ receivers.each(function(receiver){ Element.update(receiver, response); });
}
}
@@ -1778,4 +1785,4 @@
return [valueL, valueT];
}
-}
\ No newline at end of file
+}