Is is possible to attach an event handler for a menu item, or do I have to use attachEvent(“onClick”, function(id, zoneId, cas) {…} and have handlers for each possible event based on which menu item the user chose.
I am looking to add some JavaScript that runs when the user clicks on a specific menu item.
Hi,
No, you can’t attach handlers to specific menu items. You need to use a global event which will occurs for all buttons, and inside of this event handler you can check the id of clicked button and run the related action.
Please beware that above doesn’t mean, that you need to have a single huge event handler, you can attach multiple onClick handlers, separate one for each type of action.