Iv been struggling with this for a while and it seems like an important thing to be able to do with JQuery.. i need only one instance of this function to be able to run at any given time - to stop it messing up if you spam the click...
So The Questions: is there a convenient JQuery method to only run one instance of a function at a time? - if not their totally should be!!
or
am i missing some logic needed to make the variable method work?(see below.)
I have tried using a a variable methods similar to:
var wait = false; //global variable
//onclick() function starts
if(wait == true){
return false;
}
wait = true;
//function runs
wait = false; //resets wait to false at the end so it can run again
//onclick() function finishes
but this doesn't work,- I think the callback functions in my click function mess it up somehow....? original JQuery code below: (html and css can be provided as well if it helps)
$('#findUs').click(function(){
if(($('.findUs').length)&&($('.infoDropdown').is(':visible'))){ //---.length to check if class 'findUs' exists-----
$('.infoDropdown').slideToggle("slow",function(){
$('#findUs').attr('class','contactTitle',function(){
$('.findUs').remove(function(){
return false;
});
});
});
}
$('.infoDropdown').load('global/forms.php .findUs',{},function(){
$('#findUs').attr('class','selectedContact');
$('#phoneUs').attr('class','contactTitle');
$('#faxUs').attr('class','contactTitle');
if($('.infoDropdown').is(':hidden')){
$('.infoDropdown').slideToggle("slow");
}
});
});