jquery call back function -
i have call function follows
$('#lnkclientdata').click(function() { $('#clientdiv').slidetoggle(function(){ if($('#lnkclientdata').hasclass('open')) { $('#divnext').slidetoggle(); $('#lnkclientdata').removeclass('open').addclass('close'); } else { $('#divnext').slidetoggle(); $('#lnkclientdata').removeclass('close').addclass('open'); } } ); });
i want $('#divnext').slidetoggle();
code executed before outside $('#clientdiv').slidetoggle()
function.... right outside function gets called first....what trying hide anchor when div
slides in...but happens before div
slides in...
if($('#clientdiv').is(':visible')) { alert(''); // $('#divnext').hide(); //$('#clientdiv').slidetoggle(); // or whatever animation want } else { //$('#clientdiv').slidetoggle(function() // or whatever animation want //{ // $('#divnext').show(); //}); }
you need reorder code (without knowing specifics of slidetoggle implementation, i'm assuming parameter callback when slide finished)
$('#divnext').slidetoggle(function() { // code here executes after slide finished before clientdiv starts $('#clientdiv').slidetoggle(function() { // code here executes after both slides done }); });
edit:
in situation, using 1 slidetoggle method show / hide client div not best idea.
if($('#clientdiv').is(':visible')) { $('#yourlink').hide(); $('#clientdiv').slidedown(); // or whatever animation want } else { $('#clientdiv').slideup(function() // or whatever animation want { $('#yourlink').show(); }); }
Comments
Post a Comment