Kokesh
Kokesh

Reputation: 3263

Raphael JS - disable HREF in the drawing

I am using Rapheael to draw a control Dashboard. Right now I am adding a hyperlink object into the Dashboard editor. It is a text with the HREF attribute. When I add the element and click on it, it opens the link. Is there some way to temporarly disable the link? When I click the other elements, it opens the property dialog. I would like that also with the Hyperlink object.

I've tried adding return:false, but didn't help:

obj.dblclick(function (event) {
        jQuery('##divProperties').dialog('open');
        return false;
    });     

Upvotes: 1

Views: 470

Answers (1)

Jed Watson
Jed Watson

Reputation: 20378

Returning false is a way to cancel events with more traditional event binding, e.g.

obj.onclick = function() { return false }

or

<a onclick="return false;"></a>

But it doesn't work with jQuery event bindings.

To do that, you need to call the .preventDefault() method on the event object, which is passed to the event handler:

obj.dblclick(function (event) {
        jQuery('##divProperties').dialog('open');
        event.preventDefault();
    });

You may want to prevent default on the click event also if you're capturing double click so it doesn't get fired either.

Upvotes: 1

Related Questions