[Dojo-interest] Idea for instant widget construction

Cameron Braid cameron at braid.com.au
Fri Apr 7 01:37:46 MDT 2006


I have an idea that I would like to share about how to construct widgets
as the document is loading, which enables them to be activated
immediately, instead of having to wait till onload is called.


        javascript code :
        
        dojo.widget.createInline = function(tagName, params) {
                var id = dojo.dom.getUniqueId();
                var divString= "<div id='" + id + "'></div>";
                document.write(divString);
                var div = document.getElementById(id);
                dojo.widget.createWidget(tagName, params, div);
        }
         
        usage in html :
         
        <h2>look at my widget :</h2>
        <script>dojo.widget.createInline('DateSelect')</script>
         
        <h2>look at my widget :</h2>
        <script>dojo.widget.createInline('DateSelect',
        {id:'dateSelect'})</script> 

An alternative, which still uses the <div dojoType=''> notation could be
like this :

        <h2>look at my widget :</h2>
        <div dojoType='DateSelect'
        id='dateSelect'></div><script>dojo.widget.parsePreviousNode()</script> 
        
        parsePreviousNode would  look in the dom for the previous node
        that is a widget type node, and trigger the dojo widget parser
        to construct it.

Cheers,


________________________________________________________________________
Cameron Braid
PGP Public Key http://braid.com.au/cameron.pgp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mastodon.dojotoolkit.org/pipermail/dojo-interest/attachments/20060407/41e6e01f/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://mastodon.dojotoolkit.org/pipermail/dojo-interest/attachments/20060407/41e6e01f/attachment-0001.pgp


More information about the Dojo-interest mailing list