We are developing a web app. with 4 trees. One of them no longer allows iPhone users to open tree branches without closing them immediately. I added the following event handlers:
product_tree_1.attachEvent( 'onOpenStart', function( id, state )
{
alert( "open state was '" + state + "' (onOpenStart)" );
return( true );
});
product_tree_1.attachEvent( 'onOpenEnd', function( id, state )
{
alert( "open state is '" + state + "' (onOpenEnd)" );
return( true );
});
In Safari and MobiOne (a free iPhone emulator), I get the following 2 (expected) pop-ups:
- open state was ‘-1’ (onOpenStart)
- open state was ‘1’ (onOpenEnd)
However, on an iPhone (or iTouch), I get the following 3 pop-ups:
- open state was ‘-1’ (onOpenStart)
- open state was ‘1’ (onOpenEnd)
- open state was ‘1’ (onOpenStart)
- open state was ‘-1’ (onOpenEnd)
- open state was ‘-1’ (onOpenStart)
- open state was ‘1’ (onOpenEnd)
- open state was ‘1’ (onOpenStart)
- open state was ‘-1’ (onOpenEnd)
What would you suggest the problem is? What would you recommend I do next to find the problem?
Thanks in advance,
Mark M. Young
Are you using dyn. loading mode in problematic tree?
When the same code was used against normal tree - it produces only 2 events ( openstart and openend ) as expected - was tested with iTouch(3G)
Yes, it’s dynamically loading from XML.
This is also being used with the WebApp framework from WebApp.net and the iScroll script available from Cubiq.org. From the time the user loads the pages and navigates the screens/divs, additional onOpen handlers are added to the dhtmlXTreeObject even though it’s initialized only once.
Ideas?
I’ve even put…
alert( "Attaching handlers." );
product_tree_1.attachEvent( 'onCheck', function( id, checked )
{
alert( "checked state is '" + checked + "' (onCheck)" );
return( true );
});
product_tree_1.attachEvent( 'onOpenStart', function( id, state )
{
alert( "open state was '" + state + "' (onOpenStart)" );
return( true );
});
product_tree_1.attachEvent( 'onOpenEnd', function( id, state )
{
alert( "open state is '" + state + "' (onOpenEnd)" );
return( true );
});
…and the user gets the ‘Attaching handlers.’ pop-up once, and only once. Additionally, every handler attached to the tree is invoked multiple times starting with twice on page load and increasing thereafter.
Any suggestions to resolve this or repeatedly force it to have only one handler is greatly appreciated.
A co-worker and I developed the following work-around.
var g_event_timeout = 300;
var g_accept_check = true;
function onBeforeCheck_handler( id, state )
{
var l_accept_check = g_accept_check;
if( l_accept_check )
{
g_accept_check = false;
setTimeout( 'g_accept_check = true;', g_event_timeout );
}
return( l_accept_check );
}
var g_accept_open = true;
function onOpenStart_handler( id, state )
{
var l_accept_open = g_accept_open;
if( l_accept_open )
{
g_accept_open = false;
setTimeout( 'g_accept_open = true;', g_event_timeout );
}
return( l_accept_open );
}
…
product_tree_1.attachEvent( 'onBeforeCheck', onBeforeCheck_handler );
product_tree_1.attachEvent( 'onOpenStart', onOpenStart_handler );
We have tested the locale sample with dynamic loading too - the problem wasn’t confirmed.