Using a dynamic action to run javascript on clicking a tree leaf instead of opening the link.
The dynamic action has
Selection Type jQuery selector
Selector .leaf > a
Event click
Action Execute JavaScript Code
The javascript code
var element = this.triggeringElement,
vUrl,
vHref,
vParent;
/*The triggering has no id attribute
**luckily its parent does
**set aside we need it later*/
vParent=element.parentNode.id;
/*Get the attribute with the name href of the link*/
vHref=element.attributes.getNamedItem('href').value;
/*If the href is not #
**link is not clicked before
*/
if (vHref !=='#'){
/*Get the url including the base url*/
vUrl = element.href;
/*Store the url in a data attribute of the parent*/
apex.jQuery('#'+vParent).data('page_url',vUrl);
/*Set the href attribute to #
**so the link doesn't go any where*/
element.href = '#';
} else {
/*Leaf is already clicked
**get the url from the parent
**it is stored in a data attribute
*/
vUrl = apex.jQuery('#'+vParent).data('page_url');
}
/*Open the url in a new window*/
window.open(vUrl,'_blank');
/*Prevent the default behaviour of the link*/
return false;