dojo: widget already registered error -
i know seems common error , have tried implement jquery or dojo code fix problem nothing has helped far--i keep getting same error: widget registered id...
here code:
$( "div" ).remove( "#div_temperature_legend" ); //jquery dojo.create("div", { id: "div_temperature_legend", innerhtml: "<p></p>" }, "legendpanel"); var legend = new esri.dijit.legend({ map: map, layerinfos: [{ layer: layer, title: "temperature" }], }, "div_temperature_legend"); legend.startup(); the above code in button click function , function part of large dojo require() function; , works first time. jquery line seem remove because legends don't duplicated in newly created div_temperature_legend layer.
anyway, have tried dojo's destroy() function still same error. guess somehow, somewhere need register div , destroy it. how? where? in context of code?
ideally, code should detect widget if exists , doesn't create legend.
thanks.
the error resides in wrong disposal of dojo widget. once created, set in registry hash id. either a) dispose widget dojo way or b) create unique id widget each time.
in case have multiple widgets of same kind use of id not idea. better skip id , use class attribute instead. id auto-assigned have no interest in selector use class name assigned.
Comments
Post a Comment