Monday, 20 July 2009 10:37

If you've ever done any scripting using the Mootools library that ships with Joomla, perhaps you've come across a situation where you needed to prevent a link from following it's assigned location. Mootools has a function for Events called 'stop', but it is not extended to Events in 1.11. So how do you stop the link from following it's href?

The answer is to create a new Event using the already existing Event, and use the 'stop' method on that. Here's a simple script that shows this in action:

window.addEvent( 'load', function( e )
{
  $$('#targetdiv a').each( function( el )
  {
    el.addEvent( 'click', function( ce )
    {
      new Event( ce ).stop();
      alert( el.getProperty( 'href' ) );
    });
  });
});

Here's an example to show it in action:

Last Updated on Monday, 20 July 2009 10:47
 

Add your comment

Your name:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries. Jeff Channell is not affiliated with or endorsed by Open Source Matters or the Joomla!® Project.

Santorum
Joomla Extensions