Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

The MooTools event object


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.

Using event object methods

There are three event methods: preventDefault, stopPropagation, and stop.

Preventing the default behavior

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...