Working with menu events
The menu widget defines a series of useful options that allow you to add callback functions to perform different actions when certain events exposed by the widget are detected. The following table lists the configuration options that are able to accept executable functions on an event:
Event |
Triggered when… |
---|---|
|
The menu loses focus |
|
The menu is created |
|
The menu gains focus or when any menu item is activated |
|
A menu item is selected |
Each component of the library has callback options (such as those in the previous table), which are tuned to look for key moments in any visitor interactions. Any functions we use within these callbacks are usually executed before the change happens. Therefore, you can return false
from your callback and prevent the action from occurring.
In our next example, we will look at how easy it is to react to a particular menu item being selected, using the standard non-bind technique. Remove the final <script...