bug^君 2010-11-14 03:54 采纳率: 25%
浏览 50

Ajax页面加载-Dojo

Hi I have a page with a navigation menu on the left and when any link on this menu is clicked , an Ajax get call is sent to the server and the right side gets updated with the new page.

How I am currently doing this is by creating 2 columns, the left col contains the navigation link and the right col contans a div named the content which has a dojotype of dojox.layout.ContentPane.Now when the data is received from the server, I change its content like this

dijit.byId("thecontent").setContent=data

Now when I click on the navigation link , the right side gets displayed properly(this page has dijits and also some scripts to handle onclick events). But firebug returns an error saying

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

my main dojo include looks like this:-

<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.5/dojo/dojo.xd.js"djConfig="parseOnLoad:false"></script>

I do a dojo.parser.parse() in the function dojo.addOnLoad like this:-

 dojo.addOnLoad(function(){
     dojo.require("dijit.form.Button");
     dojo.require("dijit.form.Textarea");
     dojo.require("dijit.form.ValidationTextBox");
     dojo.require("dojox.layout.ContentPane");
     dojo.require("dijit.Editor");
   dojo.addOnLoad(function(){
        dojo.parser.parse();
        sendgetrequest();//this initiates the xhrget request
        dojo.removeClass(dojo.byId("doc3"),"hiddendiv");
        }

);
    })

I am also unable to run any scripts in this new loaded page. No onclick event is working, just the dijit widgets are displayed...

  • 写回答

1条回答 默认 最新

  • weixin_33716557 2011-07-13 09:05
    关注

    The error means, as Ken already said, that you are creating a dijit with an id that already exists. My guess would be that you load the AJAX content in the right panel without destroying the old right panel first.

    Try calling destroyRecursive on the main dijit container in the right panel before loading the new content. Also, if you do not need to set the id of the dijit, you just might drop the id (but that would leave a memory hole because the old dijits are not destroyed).

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器