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. And that works beautifully the first time. The second time however I end up running into a problem where it just shows the content no longer activated or styled.
On a second run what I do is remove all the html in the div and then replace the html with basic unparsed text and then I parse it again. Now I am guessing it has to do something with dijit.registry however I can not find exactly what the issue is as I have tried clearing that out as well to no avail. Your help would be much appreciated.
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"