开发者

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

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:

Erro开发者_如何学编程r: 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


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?


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();
   }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜