YUI Plugin: Dispatcher

2007-11-25
Dispatcher Manager

The Dispatcher plugin was created to satisfy a very common need of developers using the YUI library: dynamic execution of Ajax response content. Typical strategies to fulfill this need, like executing the innerHTML property or referencing remote scripts, are unreliable due to browser incompatibilities. The Dispatcher plugin avoids those problems.

This component do not required the Bubbling Core Object, only YUI Core, YUI Connection Manager, YUI Dom and YUI Event. And it guarantees these three points::

  • All of the dynamic contents (loaded thru the YUI Connection Manager) will be processed by the Dispatcher, and the javascript chunks will be executed (remote and inline scripts)
  • All the javascripts within a content will be executed according to the order of apparition.
  • All the contents will be included in the DOM's structure before beginning the execution process. This means that you can use references to an element within the container.

The last release of the dispatcher support cross-domains capabilities using the most common technique (proxy), also introduce two new method "jsLoader" and "cssLoader", for remote script and CSS loading onDemand and the hashtable to discard multiple execution for the same remote file, and path-correction for remote files if you need it.

13 Comments

Minor grammar and word use comments

On the page , I noticed a couple simple grammar and word use problems that you might want to know about.

First, the two sentences starting with "The Dispatcher plugin ..." are very hard to digest.

The following is an attempt to rewrite this in a form I can understand (but I may be missing something you're trying tto impart):

The Dispatcher plugin was created to satisfy a very common need of developers using the YUI library: dynamic execution of Ajax response content. Typical strategies to fulfill this need, like executing the innerHTML property or referencing remote scripts, are unreliable due to browser incompatibilities. The Dispatcher plugin avoids those problems.

Second, the phrase "... order of apparition" should probably be "... order of appearance". If you look up "apparition" in the dictionary, you'll see that's not quite the right word.

Comment by David Karr - April 27, 2008

Where to post specific questions

Halo all,
Which type of CMS library specific questions do we post here or should they all go through the YUI group?

Comment by George Aslanis - September 15, 2008

RE: Where to post specific questions

Hey George,

You can post in the YUI Group, or just email me directly.

Comment by Caridy - September 15, 2008

Is this now compatible with YUI 2.6.0?

Have you tested this with the new YUI 2.6.0? Is it compatible?

Comment by Cody Burleson - November 13, 2008

RE: Is this now compatible with YUI 2.6.0?

Hey Cody, the dispatcher 1.5 can work on top of YUI 2.6.0 without any problem. In fact if you check this website, you will see that the bubbling library 1.5 is working on top of 2.6.0.

Anyway, if you have any problem, just let me know.

Comment by Caridy - November 13, 2008

Dispatcher and Layout Manager

I've read elsewhere - on the Yahoo groups I think - that Dispatcher should also work with Layout Manger. I know you don't have any of the specific pre-built stuff finished yet, but it is possible to use it and if so, could you send me a small example?

Thanks

Comment by Dennis - November 18, 2008

Re: Dispatcher and Layout Manager

Hey Dennins:

You're right, in the YUI 2.6.0 I wrote the routines for AJAX within the layout manager (the same routines that we use in the tabview). The dispatcher can extend this functionality to execute the scripts.

Unfortunately this new functionality is not documented yet in the YUI 2.6.0, and also the Bubbling 1.5 don't support it yet.

But here is an example running on top of YUI 2.6.0 and Bubbling Library 2.0 beta.

http://bubbling-library.com/sandbox/yui2/dispatcher/layout.html

If you want more information, send me an email.

Comment by Caridy - November 18, 2008

dispatcher and uploader plugin together

Hi,

I posted this message at YUI Group too.

I try to use dispatcher and uploader plugin together.

I use html file with javascript inside as it is described in 'Advanced Uploader Example With Additional POST Variables and Server Data Return' for Ajax call.

When I try to upload I get 'uploader is not defined'.

Are these two plugins compatible to each other?

any help, please?

Thanks

Comment by Gia - December 16, 2008

RE: dispatcher and uploader plugin together

Hey Gia, I don't see how the dispatcher can affect the uploader utility. Do you have a test case of something where I can dig a little bit?

Also, the only way I see we can use it together is to using distpacher.process to process the response from the uploader. Is that the way you want to use it?

Comment by Caridy - March 18, 2009

fail to excute a js in ie with yui version 2.7.0

Hi, i have try the dispatcher with yui version 2.7.0 in ie. And found that, if the js in reponse is calling a js function already in current page. then the js with not be excuted. any ideas?

Comment by allen - November 12, 2009

fail to excute a js in ie with yui version 2.7.0

but it works in firefox

Comment by allen - November 12, 2009

fail to excute a js in ie with yui version 2.7.0

i mean, the inline js in response is executed, but not the remote one.
Thanks

Comment by allen - November 12, 2009

RE: fail to excute a js in ie with yui version 2.7.0

Hello Allen,

Are you using the dispatcher latest version? If that's the case, try to verify the path, probably you will have to use path-correction option in dispatcher, or verify that all the requirements to execute that file are in place. And finally, you can try to include the external file as part of the original content just to double check that it works in IE.

Also, you should check the inline block, it if fails, then dispatcher will abort the execution process and probably the remote file will never be executed.

Best Regards,
Caridy

Comment by Caridy - March 25, 2010
Bubbling for YUI 3.x

Dispatcher (gallery-dispatcher)
The Dispatcher satisfies a very common need of developers using the YUI library: dynamic execution of Ajax response content. (new)

Node Accordion (gallery-node-accordion)
The Accordion Node Plugin makes it easy to transform existing markup into an accordion element with expandable and collapsible elements. Elements are easy to customize, and only require a small set of dependencies. (new)

Event Binder (gallery-event-binder)
Binding user actions until a particular YUI instance become ready, and the listeners defined before flushing those events through a queue. This will help to catch some early user interactions due the on-demand nature of YUI 3. (new)

Preload (gallery-preload)
Port of Stoyan Stefanov's JavaScript preload() function. It also has built-in support for Timer Idle to preload files only when the user is idle to avoid any overhead during the initial loading process. (new)

Parent Window Utility (gallery-parent-window)
This utility provides a set of functionalities to interact with the parent window. (new)

- See more modules by Caridy.

Bubbling Library is free open source software under the BSD License

(c) 2006 - 2010 Caridy Patino. All Rights Reserved.

This is one of my side projects, if you need something, just ask!