Copyright © tutorialspoint.com

Prototype Event stop() Method

previous next


Advertisements

This method stops the event's propagation and prevents its default action from being triggered eventually.

There are two aspects to how your browser handles an event once it fires up:

Because stopping one of those aspects means, in 99.9% of the cases, preventing the other one as well, Prototype bundles both in this stop function. Calling it on an event object stop propagation and prevents the default behavior.

Syntax:

Event.stop(event);

Return Value :

Example:

Here's a code snippet that prevents a form from being sent to the server side if a certain field is empty.

Event.observe('signinForm', 'submit', function(event) {
  var login = $F('login').strip();
  if ('' == login) {
    Event.stop(event);
    // Display the issue one way or another
  }
});

previous next

Copyright © tutorialspoint.com