On Monday, March 26, 2012 5:50:27 AM UTC+2, Aaron wrote:
> Delegator attaches to the document.body and looks for events that bubble
> up (like click for example). It doesn't need re-application.
> Behavior flags elements that have been instantiated so when it encounters
> them again it skips them (unless you force it).
> In theory, you should be able to run b.apply(document.body) a dozen times
> without ill-effect. When creating new DOM nodes (via Ajax or otherwise)
> it's better to only do it to the container you are injecting it in instead
> of the document.body as it does have to check, but that check isn't super
> expensive. If you look at the examples on dev.clientcide.com of the
> Delegator.Ajax triggers you'll see how it fetches new data and runs the new
> elements through behavior. Don't forget to cleanup any elements you destroy.
> On Sun, Mar 25, 2012 at 3:48 PM, Rolf-nl <plentyofr...@gmail.com> wrote:
>> I have Behavior setup in domready pretty much standard like:
>> var b = new Behavior();
>> b.passMethods({
>> //nothing now
>> });
>> b.apply(document.body);
>> var d = new Delegator({
>> getBehavior: function(){ return b; }
>> }).attach(document.body);
>> On some click events (using Delegator) I request (JSONP) additional data.
>> With the data that is returned I create new links that are injected into
>> the dom, and I also want to add delegator triggers for various things. How
>> do I re-init Behavior/Delegator correctly to get this working. If I just
>> do new Behavior().apply(document.body); it works, but doesn't look right.
>> The docs state: [..] It will only invoke a filter once, so it's safe to
>> run it more than once (if the DOM changes, for example).
>> But should I run Delegator too, is there a better way? TIA
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Clientcide" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/clientside/-/2TclAowLv-cJ<https://groups.google.com/d/msg/clientside/-/2TclAowLv-cJ>
>> .
>> To post to this group, send email to clientside@googlegroups.com.
>> To unsubscribe from this group, send email to
>> clientside+unsubscribe@googlegroups.com<clientside%2Bunsubscribe@googlegro ups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/clientside?hl=en<http://groups.google.com/group/clientside?hl=en>
>> .