The MooTools event object, which is part of the native component, is what allows us to create and work with events. It's therefore worth it to take a bit of time to explore the events object.
There are three event methods: preventDefault, stopPropagation
, and stop
.
An event usually has a default behavior; that is, it has a predefined reaction in the instance that the event is triggered. For example, clicking on a hyperlink will direct you to the URL that href
property is assigned to. Clicking on a Submit input field will submit the form to the value that the action
property of the form element is assigned to.
Perhaps you want to open the page in a new window, but instead of using the non-standard target property on an<a>
element, you can use JavaScript to open the page in a new window. Or maybe you need to validate a form before submitting it. You will want to prevent the default behaviors of an event...