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?”.
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
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
This is a great article. I’m new to blogging but still learning. Thanks for the great resource.
Great article I am a designer but just getting into blogging
Trevor Seabrook
Mythic Tech
http://www.mythictech.ca