Dhtmlxmenu will error when click to close a window

in file dhtmlxmenu.js v5.0, about line 468:

this._doOnClick = function(id, type, casState) {
		......
		//
		if (this.checkEvent("onClick")) {
			this.callEvent("onClick", [id, this.conf.ctx_zoneid, casState]);
		} else {
			if ((type.charAt(1) == "d") || (this.conf.mode == "win" && type.charAt(2) == "t")) return;
		}
		if (this.conf.context && this._isContextMenuVisible() && this.conf.ctx_autohide) {
			this._hideContextMenu();
		} else {
			// if menu unloaded from click event
			if (this._clearAndHide) this._clearAndHide();
		}
	}

in above code, if a menu item is to close the window, then after this.callEvent(“onClick”…), the dhtmlxmenu will be destructor and unload, then this.conf will be null, and call this.conf.context will error.

thanks!

Unfortunately the problem cannot be reconstructed locally.
Could you please, provide a complete demo, where it can be reproduced.
Here you can find a tutorial about creating a complete demo:
docs.dhtmlx.com/tutorials__auxi … pport.html

below is the full code:

[code]

Integration with dhtmlxMenu div#winVP { position: relative; height: 350px; border: 1px solid #dfdfdf; margin: 10px; } var dhxWins, w1, myMenu, myGrid;
	function doOnLoad(){
		dhxWins = new dhtmlXWindows();
		dhxWins.attachViewportTo("winVP");
		w1 = dhxWins.createWindow("w1", 20, 30, 400, 280);
		w1.setText("dhtmlxMenu");
		w1.button("close").disable();
		//
		myMenu = w1.attachMenu({
			items:[
				{id:"file", text:"file", items:[
					{id:"close", text:"close"}
				]}
			]
		});
		
		myMenu.attachEvent("onClick", function(id, zoneId, cas){
			if(id == "close")
			{
				w1.close();
			}
		});

	}
	
	function doOnUnload() {
		if (dhxWins != null && dhxWins.unload != null) {
			dhxWins.unload();
			dhxWins = w1 = myMenu = myGrid = null;
		}
	}
	
</script>
[/code]

when click the menu item file->close, you will see the error on chrome’s console.
12_menu.zip (813 Bytes)

Please, try to close your window with a timeout:

myMenu.attachEvent("onClick", function(id, zoneId, cas){ if(id == "close") { setTimeout(function() {w1.close()}, 50) } });