Shadowbox onOpen

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Shadowbox onOpen

Sebarry
Hi,

I was wondering if someone could advise me on how to use the onOpen, onFinish functions (I'm using prototype syntax) to make sure that a function is only invoked once shadowbox has opened and is ready.

Currently what I'm using is:

function openShadowbox( type, filename )
{
        Shadowbox.init();
       
        Shadowbox.open({
        type:       type,
        content:    filename,
                height: 1200,
                width: 1200,
                onOpen: function(){ test(); }
    });
}

function test()
{
        alert( "Test is: " + document.getElementById( 'image' ).src );
}

However, at the test function isn't being invoked at all.

Thanks,

Sean
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox onOpen

Wizzud
onOpen is a property of the options object, not a property of the object expected by Shadowbox.open().
 
Shadowbox.init();
function myOpen( cacheElem ){
  alert( 'onOpen callback triggered' );
}
function openShadowbox( type, filename ){
  Shadowbox.open(
    { type : type
    , content : filename
    , height : 1200
    , width : 1200
    , options : { onOpen : myOpen }
    } );
}
 
Alterntively, simply put the onOpen into the init(), eg Shadowbox.init( { onOpen : myOpen } ); , and leave it out of the Shadowbox.open() call altogether.
Combine literacy with curiosity and a whole world of information opens up to you