Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#5438 closed defect (invalid)

Already registered widget (error message on 1.0)

Reported by: singhan@… Owned by: anonymous
Priority: blocker Milestone:
Component: Dijit Version: 1.0
Keywords: Cc:
Blocked By: Blocking:

Description

Already registered widget (error message on 1.0)

I'm currently testing dojo 1.0.0 version. on a perfectly working page with the 0.9, i've got an error message:

"Tried to register widget with id==layout but that is is already registered"

(this Id is used for a dijit.layout.LayoutContainer? object.)

It happens whenever dojo.parser is called and that widget was created before. Well I had it all throughout my application, as all things are created on fly, and then I need to it again and again unless this error is fixed, am not sure I can go ahead and redesign everything.

There should atleast be a way of unregistering that id if it is the cause of problem

Change History (4)

comment:1 Changed 10 years ago by bill

Cc: singhan@… removed
Component: GeneralDijit
Milestone: 1.0.3
Reporter: changed from guest to singhan@…
Resolution: invalid
Status: newclosed

Sorry, this is by design. Every widget must have a (possibly auto-generated) id, and Dijit doesn't support changing the id after the widget is created. This is because we have hash(es) based on widget id, and IIRC we have other places too where one widget points to another by ID. One easy way to solve your problem is to use auto-generated id's rather than hardcoding id's into your app.

comment:2 Changed 10 years ago by guest

Resolution: invalid
Status: closedreopened

Thats fine, but I need thise ids later to target these widgets. Anyways you guys were mentioned there would be backward compatibility from 0.9 onwards, isnt it breaking that rule ?

If nothing can be done, can you please suggest some way of unregistering all ids forcibly?

comment:3 Changed 10 years ago by Adam Peller

Resolution: invalid
Status: reopenedclosed

user should take this to the support forums, according to the DOU. also, please consider the use of 'blocker' severity as blocking the project, e.g. a bootstrap issue

comment:4 Changed 10 years ago by dante

fwiw, calling .destroy() on a widget unregisters the id. this is the documented accepted way of removing a dijit from the dom. destroyRecursive is the documented accepted way of removing a dijit and it's children widgets from the dom.

to force a list of id's to unregister (assuming you haven't haphazardly removed them from the dom first), something like:

var ids = ["cp1","cp2","cp3"];
dijit.registry.forEach(function(w){ 
   if(dojo.indexOf(ids,id)){
        w.destroyRecursive();
   }
});

should work. "all id's" would be easier.

Note: See TracTickets for help on using tickets.