Joust allows you specify your own functions to execute when in response to certain menu item events. These events are:
The first three you will recognise as standard JavaScript events (although onMouseOut is not supported by MSIE 3) and get called as you would expect (note that an entry must have a URL associated with it or showAllAsLinks must be true for events to be triggered for it). The fourth, onToggle, is triggered when a user expands or collapses a submenu.
You can specify an event handler by setting a property of the same name in the appropriate menu entry. For example:
theMenu.entry[entryID].onClick="myClickFunction()";
The value of an event property can be any valid JavaScript expression. Joust executes it at the appropriate time by using the eval statement. This happens in index.htm so any references to other frames must be defined relative to index.htm.
Before evaluating the event property, Joust will set the variable 'me' to the current menuEntry object. This gives you a way of accessing the entry that the event is from. For example, if you defined a function like this:
function myToggleFunction(theEntry) { if (!theEntry.isopen) { //The entry is about to be expanded. //Do some 'onExpand' processing here } }
Then you would define the onToggle event like this:
theMenu.entry[entryID].onToggle="myToggleFunction(me)";
Note: The onClickFunc used in previous versions of Joust is still supported but may be removed in the future.
As with normal JavaScript events, event processing can be cancelled by returning false from your function. So, if you wanted to stop a clicked entry from loading you would return false from your onClick handler. If you wanted to stop a folder from collapsing you check it's current state (me.isopen) in an onToggle handler and return false if it is currently open.