[Dojo-interest] Dojo without dojo special tag attribs

Matthew Weier O'Phinney matthew at zend.com
Thu Aug 7 14:17:54 UTC 2008


-- Michał Zieliński <zielun at gmail.com> wrote
(on Thursday, 07 August 2008, 06:59 AM -0700):
> Thanks Peter for all the info.
> It seems to be enough for me to start and get into Dojo world, hopefully ;)
> 
> I used to work with jQuery which I fount very useful and easy to  quick
> adoption. It`s just simple and powerfull.
> To be honest, Zend Framework and its Dojo built-in component is the thing
> why I decided to give dojo another chance. 

Well, I for one am glad to hear that. :)

The technique Peter noted that we're using in ZF is... actually his
idea. :) And it's solid. We have the ability to use either declarative
or programmatic dojo, and both work exactly the same; as a result, we're
defaulting to programmatic, to accomodate the many vocal proponents of
standards.

As Peter noted, all dijits instantiate basically the same:

    new dijit.<whatever>(<object of config values>, <dom node or ID>)

Sprinkle these inside an addOnLoad() closure, and you're good to go.

If you're marking up your HTML with good identifiers, it makes it
trivial to use Dojo to decorate your page.

> When I looked first at dojo examples I fount it strange, ugly and
> complicated. That`s why I decided to look for another js lib in the
> past. I wonder how many people react similar.

I did at first, and then started reading about _why_ Dojo chose to do
this, and quickly decided it made sense. While I appreciate standards, I
also buy the argument that the current HTML standards are outdated and
basically broken when it comes to modern web UI design.

That said, it's also nice to run a page through the W3C validators and
come back with the response that it validated. :)

> I like tidy html so I`m glad that you consider to extend docs with
> some examples for guys like me ;)

> Peter E Higgins-2 wrote:
> > 
> > Michał Zieliński wrote:
> >> Hi.
> >>
> >> I`m new to Dojo and I`d like to play with it a bit more.
> >> I like simplicity and don`t like mess in HTML code. Simple tags with ids
> >> or
> >> classes should be enough to write javascript stuff. Dojo needs some
> >> special
> >> atrribs in HTML tags. I read in manual that there is an option to use
> >> Dojo
> >> without this attribs. 
> >>
> >>   
> > Nope, the dojoType attribute is optional.
> > 
> > <div dojoType="dijit.TitlePane" id="myTitlePane" 
> > title="Wonderbar!">Content</div>
> > 
> > can be expressed without the parser like:
> > 
> > new dijit.TitlePane({ title:"Wonderbar" }, "myTitlePane");
> > <div id="myTitlePane">Content</div>
> > 
> >> Could you please tell me if the is any tutorial/article/note which
> >> describes
> >> more precisely how to achive clean HTML cooperates with Dojo?
> >> It would be nice to have some examples.
> >>
> >>   
> > The first couple examples come to mind:
> > http://higginsforpresident.net/2008/08/dojo-degradability/
> > http://turtle.dojotoolkit.org/~dante/skewDemo/demo.html (mostly valid 
> > html, new version is, but not published yet)
> > http://turtle.dojotoolkit.org/~dante/dojo.moj.oe/mojo.html (same case, 
> > just not published since update)
> > 
> > It is an aim of the new doc system to provide more copy/pastable 
> > programmatic examples. They currently exist as tests within the tests 
> > with the dojoTypes, so they are hard to spot sometimes (they don't stand 
> > out, because, well, they look like regular html ;) )
> >> (I don`t want to start discussion on standards, W3C, DTD, Validation,
> >> etc.
> >> It is my way of coding, the less the better and please don`t argue with
> >> this
> >> ;))
> >>
> >>   
> > No worries ... We have to do a lot of testing, and know the dojoType 
> > works ... it is TONS easier to offload the heavy lifting of creation 
> > onto the dojo.parser when we get into repetitious use cases, "add 
> > another example testing this tag", etc ...
> >> Regards,
> >> Mike
> >>   
> > 
> > Zend Framework offers dual declarative and programmatic options, and the 
> > way they pull it off is actually quite clever ... I have been meaning to 
> > write up a blog or something describing it, but the summary is:
> > 
> > keep a global object hash of id->widget props, onLoad, use dojo.attr() 
> > to decorate the nodes with the invalid tags, then run the parser 
> > immediately after ... the code is like 3 lines:
> > 
> > var dijitsInPage = [{ id:"foo", type:"dijit.TitlePane, title:"Hi!" }];
> > dojo.forEach(dijitsInPage, function(comp){
> >        var n = dojo.byId(comp['id']);
> >        dojo.attr(n, comp);
> > });
> > dojo.parser.parse();
> > 
> > Because validity one counts on initial page load ...
> > 
> > Hope this helps,
> > 
> > Regards,
> > Peter Higgins
> > 
> > 
> > 
> > _______________________________________________
> > FAQ: http://dojotoolkit.org/support/faq
> > Book: http://dojotoolkit.org/docs/book
> > Forums: http://dojotoolkit.org/forum
> > Dojo-interest at dojotoolkit.org
> > http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Dojo-without-dojo-special-tag-attribs-tp18864083p18871172.html
> Sent from the Dojo mailing list archive at Nabble.com.
> 
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at dojotoolkit.org
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest

-- 
Matthew Weier O'Phinney
Software Architect       | matthew at zend.com
Zend Framework           | http://framework.zend.com/


More information about the Dojo-interest mailing list