Comments (1)
  • Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

1 Moh.Maher commented Permalink

Hi Hazem,

 
When you create a DOM nodes using Dojo, it is better not to use ID attributes to refer to widgets elements in Javascript.
You can not control or maintain the uniqueness of the ids across the whole page, even if you managed to handle your widgets, you can not control other widgets created by other developers.
 
In Dojo, if you are creating some dynamic components html controls or inputs and you want to have a reference point like ID, this can be handled easily using dojoAttachPoint, where you give a place holder name to the DOM Node or a Widget. By this way you can reference it from inside the widget javascript.
You can consider dojoAttachPoint as a local variable name to the widget instance, so even if you have the same widget twice in the page, each widget code will reference its own instance at runtime, because of the way dojo creates the Ids for you.
 
Also you can consider using dojo.query() starting from a specific DOM element or a predefined dojoAttachPoint.
 
I hope that this information is helpful.