Caridy Patino![]()
The Dispatcher satisfies 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 normalize this behavior across all a-grade browsers.
Very simple example to inject two HTML fragments, one of then setting the content directly, and the other one using io. In both cases the content will be injected into a node (selector: #demo or #demoajax). In the process, the dispatcher will execute JS, and inject CSS into the current page.
<script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2010.05.21-18-16'
}).use('gallery-dispatcher', function(Y) {
new Y.Dispatcher ({
node: '#demo',
content: '<p>Please wait... (Injecting Static Markup)</p>'
}).set('content', "<p>HTML Fragment with style, link and/or script tags (eg. <style>body{color:red;}</style>)");
new Y.Dispatcher ({
node: '#demoajax',
content: 'Please wait... (Injecting External Markup: fragment.html)'
}).set('uri', 'fragment.html');
});| Subject | Author | Date |
|---|---|---|
| How to load gallery-dispatcher | alexlebek | 12/17/09 |
| Re: How to load gallery-dispatcher | Caridy Patino | 12/18/09 |
| Trouble using the dispatcher | David Robert | 03/5/10 |
| Re: Trouble using the dispatcher | Caridy Patino | 03/5/10 |
| Re: Trouble using the dispatcher | David Robert | 03/17/10 |
| Re: Trouble using the dispatcher | Caridy Patino | 03/18/10 |
| Trouble loading html fragment with script | Marc | 04/26/10 |
| Re: Trouble loading html fragment with script | Caridy Patino | 04/26/10 |
| Re: Trouble loading html fragment with script | Marc | 04/26/10 |
| Re: Trouble loading html fragment with script | Caridy Patino | 04/26/10 |
© 2010 YUI Library - Site Credits