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

Time for action—removing an event


Let's say you have some hyperlinks on a page, which when clicked, will alert the user that they have clicked a hyperlink, but you only want to do it once. To ensure that the warning message appears only once, we'll have to remove the event after it has been fired.

This type of thing may be utilized for instructional tips: when the user sees an unfamiliar interface element, you can display a help tip for them, but only once, because you don't want the tip to keep showing up every single time they perform an action.

  1. First, let's put some links on a web page.

    <a href="#">Hyperlink 1</a> <a href="#">Hyperlink 2</a>
    
  2. Next, let's create a function object which we will call whenever a click event happens on any of the links on our page. When the function fires, it will open up an alert box with a message, and then it will remove the click event from all<a> elements on the web page.

    // Create an function object
    var warning = function() ...