Hello I have a jquery autosuggest that is fading out too soon: http://www.mirochgroup.com/MirocheGroup/ <script type="text/javascript"> $(function(){ $(".search").keyup(function() { var searchid = $(this).val(); var dataString = 'search='+ searchid; if(searchid!='') { $.ajax({ type: "POST", url: "searchx", data: dataString, cache: false, success: function(html) { $("#result").html(html).show(); } }); }return false; }); jQuery("#result").live("click",function(e){ var $clicked = $(e.target); var $name = $clicked.find('.name').html(); var decoded = $("<div/>").html($name).text(); $('#searchid').val(decoded); }); jQuery(document).live("click", function(e) { var $clicked = $(e.target); if (! $clicked.hasClass("search")){ jQuery("#result").delay(4700).fadeOut('1700'); } }); $('#searchid').click(function(){ //jQuery("#result").fadeIn("1000"); jQuery("#result").delay(4700).fadeIn('1700'); }); }); </script> What am I doing wrong, Many Thanks
I have changed it to: if (! $clicked.hasClass("search")) { setTimeout(function() { jQuery("#result").delay('1500').fadeOut('2800'); },7000); } }); $('#searchid').click(function(){ //jQuery("#result").fadeIn("1000"); jQuery("#result").fadeIn('1000'); }); Still I am having trouble, it is better but still repeating the scenariois
I'm playing with setTimeout as well and noticed that timers still seem to run from previous clicks. If you have a div that shows for 7 seconds and you click anything else or even refresh the page, it seems that the timer still runs and the div can disappear what looks like too soon.