Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Tried to register widget with id==grid1but that id is already registered

Tags:

dojo

I am currently developing my personal website
and part of my site I have a biased view pr avoid duplication of code ...
and this view I have a dojox.grid.datagrid ...
I can call this view twice in the same page (ruban.phtml) the problem is that I click on 1 button that is the appeal of this view (partial view) and then I click the 2nd button that is the appeal of this view I have an error:
Error: Tried to register widget with id == grid but that id is already registered

and to address this problem, I removed the jsId walk the grid and I declared a global variable is initialized when calling the view:

grid = dijit.getEnclosingWidget(dojo.byId("gridId1");
// soit
grid = dijit.getEnclosingWidget(dojo.byId("gridId2");

I tried but I always with the same problem:

...... onDownloadEnd:function() {

          // Update the id of the grid
            var nodeGrid = dojo.byId("ancienIdGrid");
            nodeGrid.setAttribute("id", "newIdGrid");         
            varGlobalPourId = dijit.getEnclosingWidget(nodeGrid);

}....

thank you for helping me

like image 334
devMan Avatar asked Feb 08 '10 15:02

devMan


2 Answers

Dijit maintains a hash of id strings to widgets in dijit.registry (see dijit/_base/manager.js) Updating the id in the DOM will not affect that table, so I could see how it would fail if you try to create a widget with the same ID twice. How about just generating a unique id for each grid, if you need an id at all?

like image 200
peller Avatar answered Oct 21 '22 07:10

peller


destroy all registered id forcefully with this snippet than you go on your way!!

var ids = ["cp1","cp2","cp3"];
dijit.registry.forEach(function(w){ 
   if(dojo.indexOf(ids,id)){
        w.destroyRecursive();
   }
});
like image 28
Ravi Avatar answered Oct 21 '22 09:10

Ravi