$e.stopEvent Function


$e.stopEvent(event as object)



The DOM event object.


Stops an event from bubbling up the hierarchy of elements.


The $e.stopEvent() function allows you to stop an event from bubbling up through the hierarchy of elements on a page. You pass in the event object variable that was passed into the function that is handling the event.


/*This adds an event handler for the 'onkeyup' event to both the document body, and an input called 'input1'.
If the user types a key in the input, the keypressInput()  function will handle the event, and then the keypressBody() function
will ALSO handle the event (because the event 'bubbles' up through the hierarchy of element on the page. */


/*Now, assume that when the user types a key into the input, you want the keypressInput() function to be called, but NOT the keypressBody()  function.
To do this, you must stop the 'onkeyup' event from 'bubbling up'.

This is done by calling the $e.stopEvent() function inside the keypressInput() function. For example:
function keypressInput(evnt) {
    //Actual code you want to handle the keypress goes here.
    //Note: the 'evnt' variable is always passed into a function that was bound using the $e.add() function.
    //The 'evnt' variable contains information about the event that happened, such as mouse position, or key pressed.