Dojo and the script tags
Alex has written about some new script tag support added in Dojo 0.9:
For a long time systems like Flex and Laszlo have had a corner on naturally mixing behavior with markup. HTML’s native <script> tag doesn’t provide any context, and worse, can’t provide a way to be triggered by a particular event or action (outside of proprietary extensions). Several use-cases are important:
- Scoped execution
- Event-driven execution
- Attachment vs. replacement
In Dojo 0.9 we took a hard look at them and devised
<script type="dojo/method">and<script type="dojo/connect">. Lets take a quick tour and show how it makes writing event handlers natural, building new widgets a snap, and over-riding built-in behavior trivial.
So, you can take code like this:
-
-
<script type=“text/javascript”>
-
dojo.addOnLoad(function(){
-
var cp = dojo.widget.byId("cp");
-
dojo.event.connect(cp, "onDownloadStart",
-
function(){
-
dojo.debug("started downloading:", cp.href);
-
// advanced behavior here
-
}
-
);
-
-
// more configuration…
-
});
-
</script>
-
<div dojoType=“dojo:ContentPane” widgetId=“cp”>
-
…
-
</div>
-
and replace it with the script tag way of attaching an event:
This definitely looks a little different on the eyes.
Read more on the source site
No comments yet.
feel free to leave a comment
Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). All line breaks and paragraphs are automatically generated. Off-topic or inappropriate comments will be edited or deleted. Email addresses will never be published. Keep it PG-13 people!
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
All fields marked with " * " are required.

