Hai Alex Russell
Iam a Extjs Developer i want to switch to dojo everything is fine except dijit there not way to use dijit completely from javascript for forms i have to add labels and layout manualy and many widgets need html code. All the docs and examples show's HTML code. Is Dojo is a Javascript lib or a HTML lib???
Alex Russell this question is for you. Is Dojo Javascript lib or HTML lib?
Submitted by tuxhero on Sun, 03/23/2008 - 17:32.
- Login or register to post comments
- Subscribe post

This isn't really a question for Alex...
...though he can definitely answer it :)
Dijit (the widget system, which based on your post seems to be what you are interested in) is a JavaScript library. The fact of the matter is that we primarily feature HTML-based instantiation on this site (which is what an awful lot of people seem to be interested in), but any Dijit should be create-able via either markup or via JS. For example:
var w=new dijit.Menu({ // params }, someNode);...will create an instance of a Dijit Menu, using some DOMNode as the node in which to create the Dijit.
One of the things that seems confusing to a lot of people though is that we do our best to maintain some version of "degradable" or "unobtrusive" coding practices; because of this, our general attitude is that you should leverage what is available with HTML as much as possible, and use libraries like Dijit to augment (as opposed to replace).
Hope that helps.
No that does not help
I did't ask how to use dijit. I want to design a Form completly in javascript with dijit. Try to build it u will understand.
Dojo is a JavaScript toolkit
I'm not Alex, but I'm not sure I understand your concerns about Dojo HTML templates.
Dojo's ability to connect an HTML template with a js widget class is a huge advantage over Ext IMO. You can easily associate DOM elements of the HTML template to attributes of the widget class. Also, you can associate DOM event callback to methods of the class. In addition, the templates can support substitutes and embedded widgets, which become attributes of the js widget class. I looked briefly at Ext, but I couldn't find this capability.
Programmatically Creating a Form
I think the question isn't about using HTML templates, although that is an advantage over using Ext. Rather, I think tuxhero is wondering how to use Dojo to create a form solely via JavaScript, instead of embedding info into HTML tags. This is certainly possible -- as ttrenka answered this is a pretty common way to use the library.
You may want to look at the manipulating widgets through code section of the Dojo book.
Thankyou Les n pwagener for understand some of my problem
See this link n sources code of that example.
http://extjs.com/deploy/dev/examples/form/xml-form.html
It's related to HTML Templete in dijit.
something like:
something like:
var form = new dijit.form.Form({ id:"theForm" }); dojo.body().appendChild(form.domNode); var inp = new dijit.form.TextBox({ value:"username" }); form.appendChild(inp.domNode); var button = new dijit.form.Button({ label:"Submit", type:"submit" }); form.appendChild(button.domNode); dojo.connect(form,"onSubmit",function(e){ var data = dijit.byId("theForm").getValues(); dojo.xhrPost({ url:"foo.php", content: data, load: function(response){ // callback response text } });admittedly, it's not as simple as the Form class of ext having things like .addButton() methods, but all of the components are available (and a11y accessible out of the box) and also allow you to do the markup equilivant:
Submit dojo.stopEvent(e); dojo.xhrPost({ url:"some.php", content: dijit.byId("theForm").getValues() });