added beforeShow callback option to allow for enabling/disabling menu items right before the menu is displayed