I'm using dojo 1.9 for my projects. I have been following an approach where I give "id" fo each dijits that I use. For ex:
var cp = new dijit.layout.ContentPane({\
id:"myContentPane",
content:"Test"
});
is it a good practice to assign an id? Reason I do For ex, if I want to reload the cp with a new content, I check to see (by id) if the cp is already created or not. If yes, I just set the content and if not I create it. So above code gets changed to
if(!dijit.byId("myContentPane"){
var cp = new dijit.layout.ContentPane({\
id:"myContentPane",
content:"Test"
});
}else{
dijit.byId("myContentPane").set("content","new content");
}
so I use id to check if the dijit is already created or not. Very rarely, I use the id to destroy the dijit.
Regards, Manju
I think it is always a good idea to identify your widgets by an unique a reason is:
dijit/registryin a easy and concise way without querying the DOM.Example of usage: