Board Logo

Open Tree and open Link in new Frame at same time
martib - 4/5/2007 at 02:34 PM

Hi!

I have Tree Menu PRO.

I want to have if somebody clicks on a MainFolder (Parent) the tree (Child) opens and the link of the MainFolder (Parent) opens (in a frame).

So for now i have
['MainFolder','http://www.link.com',{'tw':'left_frame',},
but the comment for opening the tree is missing.

ow to get that?


tigra - 4/5/2007 at 08:00 PM

what you have now will load the frame, but it will not open the node.
If you use PRO version of the script you can use the event system and API to change that. Hook the function to "select" event. In that function call .open() method of the node and then return true to allow the default handler.


martib - 4/5/2007 at 08:59 PM

sorry, but how do i hook the function to "select" event?
and how to call .open() method of the node?

is there a similar code or example somewhere?


tigra - 4/5/2007 at 11:15 PM

There is this sample in the tree documentation:

Code:
/*
This function modifies tree behavior so nodes without link
assigned will open on single click
Function should be called AS onItemSelect handler of the tree
*/

function onItemSelectHandler (o_item) {
// if node with no link then toggle
var o_state = o_item.state();
if (o_state['node'] && !o_item.a_config[1]) {
o_item.o_root.toggle(o_item.n_id);
// cancel default action
return false;
}
// proceed to default handler
return true;
}


it should be modified to meet your requirements:

Code:
function onItemSelectHandler (o_item) {
var o_state = o_item.state();
if (o_state['node'])
o_item.open()
// proceed to default handler
return true;
}


in tree_tpl.js you add following to the configuration structure:

'onItemSelect':'onItemSelectHandler'

again, this will work only with PRO version of the script


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/