Quantcast
Channel: 3magine
Viewing all articles
Browse latest Browse all 9

Simple Javascript Confirm Message using Mootools

$
0
0

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


Viewing all articles
Browse latest Browse all 9

Trending Articles