Download page ajax - Dojo

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

How am I doing this now, having created 2 columns, the left col contains the navigation link, and the right column contains the div with the name content that has dojotype dojox.layout.ContentPane.Now, when the data is received from the server, I change its contents as follows

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

Now, when I click on the navigation link, the right side gets (there are digits on this page, as well as 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 dojo.parser.parse () in the dojo.addOnLoad function as follows: -

  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 also cannot run any scripts on this newly loaded page. There is no onclick event, only dijit widgets are displayed ...

+4
source share
1 answer

The error means, as Ken said, that you are creating a DJ with an existing identifier. I assume that you load the AJAX content in the right pane without first destroying the first right pane.

Try calling destroyRecursive in the main dijit container in the right pane before loading new content. In addition, if you do not need to set the digit ID, you can simply reset the identifier (but this will leave a memory hole, because old digits will not be destroyed).

+1
source

All Articles