Skip to content Skip to sidebar Skip to footer

Dojo And Dijit Can Not Parse Same Id Twice?

I am having a problem while working with DOJO where I will dynamically load a div with some content and then run parser.parse(dom.byId('mainDiv')); with the respective requires. An

Solution 1:

Dojo keeps track of the objects / widgets it creates by the specified id. If you run the parser again on an object with the same id, dojo tries to create a second instance, but there is already one, so it should throw an error in your js console (please check).

You could leave the id blank, then dojo / parse should create an id for you. Dojo allows you to find dom elements by class attributes, that way you could pass your div-element to the parse() function without giving it an explicit id.

Anotherway would be to destroy the created widget/object before you parse the div-element again, take a look here for that:

Dojo and unregistering widgets

Quote from http://livedocs.dojotoolkit.org/dojo/parser#parse

"If you try to parse the same content twice, or parse content mentioning id's of existing widgets, it will cause an exception about duplicate id's"

Post a Comment for "Dojo And Dijit Can Not Parse Same Id Twice?"