externalLinks fail with new plugin

38 views
Skip to first unread message

Tobias Beer

unread,
Jul 24, 2012, 2:51:53 AM7/24/12
to tiddly...@googlegroups.com
Hello everyone,

I am working on a new plugin called SimpleTreePlugin to generate trees from lists.

Here's a link to an example wiki: http://goo.gl/RvZOs

There's a bug that causes all externalLinks inside a SimpleTree to fail and I can't seem to figure out the problem.

If anyone had an idea on what could be failing here that'd be nice.

Thanks, Tobias.

chris...@gmail.com

unread,
Jul 24, 2012, 4:25:39 AM7/24/12
to tiddly...@googlegroups.com
On Mon, 23 Jul 2012, Tobias Beer wrote:

> There's a bug that causes all externalLinks inside a SimpleTree to fail and
> I can't seem to figure out the problem.
>
> If anyone had an idea on what could be failing here that'd be nice.

Just a guess, but I suspect you have a custom event handler that is firing
on 'click' for the external link that is swallowing the click and not
letting the default action happen. So I would inspect your event
handlers and see if something is perhaps returning false when it
shouldn't be.

--
Chris Dent http://burningchrome.com/
[...]

Tobias Beer

unread,
Jul 24, 2012, 8:25:08 AM7/24/12
to tiddly...@googlegroups.com
Thanks for the feedback, Chris.

I thought so, too... but I couldn't figure out the problem. There actually are two causes due to return false; statements in click handlers that result only in externalLinks (!?) to fail:


1) The click handler for List Items
I need click handlers for list items which of course may contain externalLinks but also be nested in outer list items. I thought that whenever I return false; out of an outer list item that any click handlers of inner elements have long fired. That, however, does not seem to be the case. So, how can I prevent any click handlers of parent elements from firing while not interrupting click handlers within? ... after all, lists that are to turn into trees better be nested.


2) The click handler for Links

What I want is for the parent click handler defined in 1) to be interrupted when the click handler for a link contained in a list item fires. In other words, when I click the link, I open the item but I don't open or close the folder. I thought I'd do that by doing a return false. This indeed does prevent the list handler from firing. However, while the click handler of tiddlyLinks remain functional externalLinks do not. Why is that and how can I prevent this particular failure?


I have tried using setTimeout to delay binding the click handlers hoping that the core handlers would have been chained-in before mine and thus fired first. However, besides being quite the dirty hack, this did not seem to have done the trick.

Any more suggestions are highly welcome.

Tobias.

Tobias Beer

unread,
Jul 24, 2012, 11:30:28 AM7/24/12
to tiddly...@googlegroups.com
Fixed it simply by having my click handler handle external links.

if(el.is('.externalLink')) window.open(el.attr('href'));

Cheers, Tobias.
Reply all
Reply to author
Forward
0 new messages