strange error in menubutton

When I create a menu button with ID “Menu” my script crashes. It complains that Object Class Menu has no method ‘destroy’. Soon as I rename it’s fine. Is the name “Menu” reserved?

isc.MenuButton.create(
{ID:"Menu",title:"MButton",
showEmptyMessage:false,
showDown:false,
showRollOver:false,
baseStyle:"CwMEIDef",
autoFit:true,
align:"bottom",
menu:isc.Menu.create({showDown:false,data:[{title:"testMenu"}],vAlign:"bottom"})});

This is because the default behavior is to make all major ISC classes available globally as well as via the “isc” prefix.

If you want to be able to make use of globals like “Menu”, you can turn this off, which is also a recommended practice just to be ready for possible interoperability with other applications or libraries that might need to load in the same page.

However, for the same reason, we’d recommend not using a global id like “Menu” - too common, and fairly likely to end up being used by either another application, another framework, or the browser itself (a number of applications broke back in 2003 when “toolbar” became a reserved global in early Mozilla).

A typical practice is to prefix all variables, or store all your “globals” in a single object:

window.myApp = {};
myApp.Menu = isc.MenuButton.create({...});
myApp.Menu.doSomething();

Hmm alright then. We already have a solution for naming collisions so we will just use it in this case.

Thanks!