Login Register

A few questions about dojo.connect

Let's say I have a standard HTML link with either a URL or a call to a Javascript function and it's sitting in a frame. Let's also say that I have a dojo.connect call in a separate frame that refers to that link as an object (by its ID) and connects it to standard Javascript confirm function.

I assume that this confirm function simply gets tagged on after any existing functions. Does this mean that the confirm function returning false won't block the functions that came before it?

I set something like this up and can get the confirm dialog to appear, but in IE when I hit the Cancel button it goes ahead with whatever it was doing before anyway and in Firefox it actually executes while the confirm dialog is still open (basically as if the confirm dialog didn't exist).

I don't know if this is an issue with Dojo specifically or Javascript but I was hoping someone may be able to shed some light on the matter.

Thanks,

NL

If you want to cancel the

If you want to cancel the default action of following the link, then inside your function that is bound to the click via dojo.connect, call the preventDefault() method on the event:

dojo.connect(aNode, "onclick", function(evt){
    evt.preventDefault();
});

Note that you may have other troubles if you are trying to use Dojo across frames -- some things do not translate well across frame boundaries. It is best to do the connect in the same document where the node exists.