Rookie mistake...it's because it's inside a function. I tried to make a work around but this is still not destroying the widget.
// Destroy editor
var thing2 = on(stopEdit, "click", function destroyEditor() {
if (dom.byId("editDivDyn") != null) {
var widgets = registry.findWidgets(editDivDyn);
console.log(widgets);
if (widgets) {
arrayUtils.forEach(widgets, function(w) {
w.destroyRecursive();
w=null;
});
}
domConstruct.destroy("editDivDyn");
}
});
When I use the 'create' function again I get the error: "Uncaught Error: Tried to register widget with id==editDivDyn but that id is already registered"