错误:尝试使用id == grid1注册窗口小部件,但该ID已经注册 [英] Error: Tried to register widget with id==grid1but that id is already registered

查看:374
本文介绍了错误:尝试使用id == grid1注册窗口小部件,但该ID已经注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发我的个人网站

和我的网站的一部分我有一个偏见的视图,避免重复的代码...

和这个视图我有一个dojox。 grid.datagrid ...

我可以在同一页面中调用此视图两次(ruban.phtml)
问题是我点击1按钮是这个视图的吸引力(部分查看),然后我点击这个视图的吸引力的第二个按钮我有一个错误:

错误:试图注册小编与id ==网格,但该ID已经注册



并解决这个问题,我删除了jsId走的网格,我声明一个全局变量在调用视图时被初始化:




grid = dijit.getEnclosingWidget(dojo.byId(gridId1);

// soit

grid = dijit.getEnclosingWidget(dojo.byId(gridId2);



我试过但我总是有同样的问题:




...
onDownloadEnd:function(){

  //更新网格的ID 
var nodeGrid = dojo.byId(ancienIdGrid);
nodeGrid.setAttribute(id,newIdGrid);
varGlobalPourId = dijit.getEnclosingWidget(nodeGrid);

} ....



感谢你帮助我

解决方案

Dijit在dijit.registry中维护一个id字符串到小部件的哈希(请参阅dijit / _base / manager.js)更新DOM中的id不会影响该表,因此如果您尝试使用相同的ID创建一个小部件,那么我可以看到它将如何失败。如果您需要一个ID,那么如何为每个网格生成唯一的ID?


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

解决方案

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?

这篇关于错误:尝试使用id == grid1注册窗口小部件,但该ID已经注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆