Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4128 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 2 years ago

[PATH] Ajax.Updater Multiple Receivers Support

Reported by: frangossauro@gmail.com Assigned to: sam
Priority: normal Milestone:
Component: Prototype Version: 1.0.0
Severity: normal Keywords: Path
Cc:

Description

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
+}

Attachments

NewsScrollerSetup.exe (202.9 kB) - added by anonymous on 07/10/06 10:42:14.

Change History

07/10/06 10:42:14 changed by anonymous

  • attachment NewsScrollerSetup.exe added.

10/09/06 10:01:43 changed by mislav

This ticket is now superseded by #6366.

11/04/06 18:40:43 changed by mislav

  • status changed from new to closed.
  • resolution set to wontfix.

In #6366 we agreed that this is not needed, and that for your special needs (like this) you should be better off using a callback.