Toronto web design - 3magine Inc.

1 (866) 365 2407

Levitra online Vicodin Online Propecia online

Labs

Simple Javascript Confirm Message using Mootools

As most of you know there are many ways to implement “confirm” messages for your websites, and we have come up with yet another. Confirm messages are important because without them important data could be deleted or changed by accident.

In the window event “domready” you have to add the following code:

$$('.confirm').addEvent('click',function(e){
	var msg=this.title?'Are you sure you would like to: '+this.title+'?':'Are you sure?';
    if(!confirm(msg))	e.stop();
});

After the initial code is implemented all that has to be done is to add a “confirm” class to a link and title to describe the action:

     <a href="/product/delete/43" class="confirm" title="Delete item number 43">delete</a>
     <a href="/product/save" class="confirm" title="Save current product">save</a>

When you click on the “delete” link you will be prompted with a confirm message “Are you sure you would like to: Delete item number 43?” and “save” link with “Are you sure you wouldl ike to: Save current product?”.

Thursday, April 2nd, 2009 Web Development

4 Comments to Simple Javascript Confirm Message using Mootools

  1. Hey.. how do I make it work for Mootools 1.2 ? Doesn’t work for me. Lemme know if that’s for 1.2. Maybe I’m doing something wrong, but I don’t think so ;-)

  2. h-a-r-v on June 16th, 2009
  3. This is great! It really shows me where to expand my blog. I think that sometime in the future I might try to write a book to go along with my blog, but we will see…Good post with useful tips and ideas

  4. vohvsm on June 23rd, 2009
  5. This is a great article. I’m new to blogging but still learning. Thanks for the great resource.

  6. zmgsqv on June 25th, 2009
  7. Great article I am a designer but just getting into blogging

    Trevor Seabrook
    Mythic Tech
    http://www.mythictech.ca

  8. Mythic Tech on February 15th, 2011

Leave a comment