L
lsolesen
I used the following javascript to add confirm-boxes to links. The
confirm-boxes are added at runtime for links with the class "delete".
The script adds the function to the links. When I click the link, the
confirm box i shown. But then it breaks; no matter if I press Cancel og
Ok, there is the same behavior => the link is followed. I wonder why
that is - off course I don't want to follow the link, if I select
Cancel.
var confirmboxes = {
init: function() {
confirmboxes.apply("delete");
},
apply: function(sClass) {
var elements =
YAHOO.util.Dom.getElementsByClassName(sClass, "a",
"content");
if (!elements) return;
var n = elements.length;
for (var i=0; i<n;i++) {
YAHOO.util.Event.addListener(elements,
"click", function() {
return confirm("Er du sikker?");
});
}
return false;
},
}
YAHOO.util.Event.addListener(window, "load", confirmboxes.init);
confirm-boxes are added at runtime for links with the class "delete".
The script adds the function to the links. When I click the link, the
confirm box i shown. But then it breaks; no matter if I press Cancel og
Ok, there is the same behavior => the link is followed. I wonder why
that is - off course I don't want to follow the link, if I select
Cancel.
var confirmboxes = {
init: function() {
confirmboxes.apply("delete");
},
apply: function(sClass) {
var elements =
YAHOO.util.Dom.getElementsByClassName(sClass, "a",
"content");
if (!elements) return;
var n = elements.length;
for (var i=0; i<n;i++) {
YAHOO.util.Event.addListener(elements,
"click", function() {
return confirm("Er du sikker?");
});
}
return false;
},
}
YAHOO.util.Event.addListener(window, "load", confirmboxes.init);