I recently experimented with Dojo and figured that given a single dom node in the markup, I can construct the whole UI tree in an object oriented manner i.e., programmatically and not having to worry about escaping ids and making code like data. My question is in JQuery, is the same possible. My markup has a single root div and everything else needs to be added in response to some program event. I am hearing a lot of good things about JQuery and wondered if this was possible I could switch. Could someone provide an example or pointers?
Asked
Active
Viewed 1,051 times
1
-
You mean the ability to put a "dojoType" attribute on some DOM node in your HTML markup and have it automatically "parsed" into a rich UI object? There are quite a few UI widgets for jQuery, but AFAIK nothing similar to what Dojo is offering. You can probably check the jQuery UI library... – Stephen Chung Jul 06 '11 at 09:53
-
Stephen, no my main index.html document has a single div. Everything can be added in Dojo with attachpoints and template htmls. Editing... may be you are right. – foobarometer Jul 13 '11 at 16:03
1 Answers
3
It's possible to accomplish something similar with jQuery, but jQuery out of the box doesn't have the same notion of programmably created widgets that Dojo has. The closest that jQuery offers is the Widget Factory that is part of jQuery UI -- it is somewhat similar to what Dojo offers via dijit._Widget, but it doesn't offer a notion of templated widgets like Dojo does. You also lose out on attach points and attach events.
All of that said, you can certainly use jQuery to append things to your DOM at runtime, rather than creating your DOM via HTML. The facilities for doing so just aren't as comprehensive in jQuery as they are in Dojo.

rmurphey
- 552
- 3
- 7
-
Thank you, yes I was looking for this answer. Dojo is very rich with attach points and templateString. – foobarometer Jul 13 '11 at 16:01
-
jQuery out of box is not meant for ui widgets. But there is jquery templates, also You can check out jsRender for templates. I find widget factory of jquery ui is pretty good I have no idea of dijit._Widget. But certainly jquery ui components are not vast enough to compare with dojo's. You will always need to look for plugins for jQuery. But with plugins you can get better effects than dojo. But handling too many plugins from different developers is a difficult task. – samarjit samanta Feb 07 '12 at 05:26