jquery - Prevent Javascript from being executed twice -


i have script developing creates sliding button type effect. 5 div's situated next eachother each link. when 1 of divs clicked on associated content expanded , rest of div's closed.

the problem is, if user clicks div twice while loads or clicks div in rapid succession, cracks start show.

i wondering if possible allow query executed once , wait until completion rather queuing it.

here current code, if crap feel free comment on how better it... not best @ javascript/jquery :p

    function mnuclick(x){     //reset elements     if($('#'+x).width()!=369){         $('.menu .menu_graphic').fadeout(300);         $('.menu_left .menu_graphic').fadeout(300);         $('.menu_right .menu_graphic').fadeout(300);         $('.menu').animate({width: "76px"},500);         $('.menu_left').animate({width: "76px"},500);         $('.menu_right').animate({width: "76px"},500);     }         var elementid = '#' + x;          $(elementid).animate({             width: 369 + "px"         },500, function(){              $(elementid + ' .menu_graphic').fadein(300);         }); } 

thanks in advance, chris.

you need "isrunning" flag. check before start. set when start sequence, clear when ends.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

c# - Getting "Internal .Net Framework Data Provider error 30" error when column has NULL value -

c++ - How to modify context menu of internet explorer using IDocHostUIHandler::ShowContextMenu? -