Agreed--it's hardly a revolutionary change. The case I needed it for
was a self-updating div:

<div id="foo">
<script type="text/javascript"
document.observe("foo:refresh", function(){Ajax.Replacer("foo",
"/bar/foo", {method: 'get'})});
</script>
content
</div>

If that were Updater, it would cause the div to nest itself on every update.

The other places I see it being useful are when the XHTML is either
outside of the developer's control, or it has to meet other
requirements that necessitate it not having a wrapper. More
importantly, I think it's poor taste to add cruft (ie. a wrapper div)
to your presentation layer due to the inadequacies of your behavior
layer. Especially when they're so easily fixed.

I'm not saying it belongs in core: I just saw the old post, found it
was buggy, and thought it'd be nice to have a working implementation
floating around for the next Googler. That being said, it would only
introduce 4 lines of duplicate code because it subclasses Updater. You
could eliminate those duplications by adding a bit of abstraction ;)

Cheers,
Ian

On Tue, Apr 29, 2008 at 5:13 AM, Yanick <[EMAIL PROTECTED]> wrote:
>
>  Just out of curiosity... how this is better than having a wrapper
>  element and using Ajax.Updater instead?
>
>  To me, it seems like replacing :
>
>  var str = "foo " + "bar";
>
>  with :
>
>  var str = cat( "foo ", "bar" );
>
>  function cat(a, b) {
>   return a + b;
>  }
>
>  Unless you really have to process your response in a specific way that
>  Ajax.Updater doesn't do, it is, IMHO, that it adds duplicate code to
>  the core. If I am mistaking, please help me see the light here.
>
>  yanick
>
>
>  On Apr 27, 4:51 pm, "I. E. Smith-Heisters" <[EMAIL PROTECTED]> wrote:
>  > I saw in the archives that someone was looking for an Ajax.Replacer
>  > class:
>  >
>  > http://groups.google.com/group/prototype-core/browse_frm/thread/a2fed...
>  >
>  > I found that the implementation suggested didn't work correctly with
>  > 1.6.0.1, so I just wanted to share my new implementation:
>  >
>  > Ajax.Replacer = Class.create(Ajax.Updater, {
>  >   updateContent: function(responseText) {
>  >     var receiver = this.container[this.success() ? 'success' :
>  > 'failure'],
>  >         options = this.options;
>  >
>  >     if (!options.evalScripts) responseText =
>  > responseText.stripScripts();
>  >     if (receiver = $(receiver)) receiver.replace(responseText);
>  >   }
>  >
>  > });
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to