问题
I have a div tag, lets say "mydivTag"
It has a child node under it with an ID of "childID"
I want to delete/unregister/whatever "childID" and then recreate a different node with the same ID, "childID"
How do I achieve removal of the first object with ID "childID" so that when I make my new object with that same ID, I don't get an error about there already being a widget registered with the ID "childID"
Thanks
回答1:
have you tried something like
dojo.query("#childID", mydivTag).orphan()
then
dojo.create("div", {id: "childID"}, mydivTag)
These are just shorthand for DOM APIs like removeChild and createElement
来源:https://stackoverflow.com/questions/4401278/unregister-delete-all-child-nodes-of-a-div-tag-in-dojo