Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > The confirmbox does not cancel the link behavior

Reply
Thread Tools

The confirmbox does not cancel the link behavior

 
 
lsolesen@gmail.com
Guest
Posts: n/a
 
      05-28-2006
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[i],
"click", function() {
return confirm("Er du sikker?");
});
}
return false;
},



}


YAHOO.util.Event.addListener(window, "load", confirmboxes.init);

 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      05-28-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
<snip>
> ... . 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.

<snip>
> var n = elements.length;
> for (var i=0; i<n;i++) {
> YAHOO.util.Event.addListener(elements[i],
> "click", function() {
> return confirm("Er du sikker?");
> });

<snip>

You have not posted the code for - YAHOO.util.Event.addListener - so its
mechanism is unknown. However, it looks like it does not include a
mechanism for cancelling the default action of event handlers by
returning true/false from the event handling function. The best source
of information on cancelling default actions with this code is its
documentation.

Richard.


 
Reply With Quote
 
 
 
 
Lars
Guest
Posts: n/a
 
      05-28-2006
>You have not posted the code for - YAHOO.util.Event.addListener - so its
>mechanism is unknown.


YAHOO.util.Event.addListener is documented here:

http://developer.yahoo.com/yui/docs/...til.Event.html

And the sourcecode is available here:

www.intraface.dk/yui/event/event.js

--
Lars Olesen

 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      05-28-2006
Lars wrote:
>>You have not posted the code for - YAHOO.util.Event.addListener
>> - so its mechanism is unknown.

>
> YAHOO.util.Event.addListener is documented here:

<snip>

Are you proposing that I read hundreds, or even thousand, of lines of
code that I may never use myself just to answer a question here?

Richard.


 
Reply With Quote
 
petermichaux@gmail.com
Guest
Posts: n/a
 
      05-29-2006

(E-Mail Removed) wrote:
> I used the following javascript


snip
> var elements =
> YAHOO.util.Dom.getElementsByClassName(sClass, "a",
> "content");



snip
> YAHOO.util.Event.addListener(elements[i],
> "click", function() {


snip
>
>
> YAHOO.util.Event.addListener(window, "load", confirmboxes.init);


You might have good luck asking this on the Yahoo! UI mailing list.

http://developer.yahoo.com/yui/#support

Peter

 
Reply With Quote
 
Lars
Guest
Posts: n/a
 
      06-02-2006
> You might have good luck asking this on the Yahoo! UI mailing list.

Thanks.

--
Lars Olesen

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListView. Cancel. It does not! shapper ASP .Net 0 03-06-2008 03:07 PM
Cancel button on [Enter] key press does not fire gnewsgroup ASP .Net 0 12-27-2007 03:31 PM
Datagrid cancel command does not work when adding new record Julia B ASP .Net Web Controls 2 04-11-2006 12:42 PM
HELP CANCEL CANCEL CANCEL Carmen Rosario Computer Support 7 04-06-2005 11:04 PM
confirm does not cancel postback? JerryK ASP .Net 2 03-22-2005 04:46 PM



Advertisments