enableDynamicLoading gives error when reloading menu

I have a requirement to refresh my menu programmatically. I am using enableDynamicLoading for loading my menu. The first load works fine, when i reload i get the error

Message: Object expected
URI: …/lib/dhtmlx/dhtmlxMenu/codebase/dhtmlxmenu.js
which is the line

this._xmlLoader.loadXML(this.dLoadUrl + this.dLoadSign + "action=loadMenu&etc=" + new Date().getTime());

On further investigation I found the following line in the function _xmlParser – this.destructor();
which basically nulls this._xmlLoader.loadXML and therefore it is not able to reload the menu again. Could you please advise on the best approach to progress further. Let me know if you need any further information.

Cheers
Arjun

here is the sample with dynamic loading:

dhtmlxMenu/samples/01_init/05_dynamic_loading.html

dhtmlx.com/docs/products/dht … ading.html

What should be done to recreate the problem ?

Hi,

I am using a servlet as the server side object but that shouldn’t matter. To re-create the problem please try re-loading the initMenu() function in your sample after it has been loaded for the first time. FYI I am using version 2.6 of dhtmlx.

Thanks a lot

Cheers
Arjun

initMenu() can not be called several times. As in this case 2 menus will be initialized in the same container.

To reload menu, you need to call menu.clearAll() method and then enableDynamicLoading method.

Thanks for that. I resolved the issue. Just to re-state the problem since I was not very clear initially, I was attaching a menu to a layout and then trying to re-load the attached menu once again which was given me this error. The trick lay in detaching the menu first and then attaching and loading it. Thanks again for your help.

Cheers
Arjun