Consider the following code:
<a href="#" onclick="return confirm("sure to remove?");;
new Ajax.Updater('12', '/admin/files/remove/id/12', {asynchronous:true, evalScripts:false});;
return false;">Remove
</a>
It does not work, and I am not sure why.
How can I resolve this issue?
Nothing gets executed after a return
statement. When you return, you return. That's what return
is for. Thus no code after return confirm("sure to remove?");
will ever run.
You probably want something like this:
<a href="#" onclick="
if (confirm("sure to remove?")) {
new Ajax.Updater('12', '/admin/files/remove/id/12', {asynchronous:true, evalScripts:false});
}
return false;">Remove</a>
Although it would be much better to create a proper function and call that instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.