[jQuery] Newbie: simple and own autocompletor
Hello @ all,
first i wanna thank you guys from jquery for the absolutly definitly
amazing lib!!!
I was looking for a simple autocompletor in the plugins section and
found the one from the Interface plugin,
but this one isnt working right now cause of the update of jquery to
1.0.2. Overall it needs a xml response,
wich i wont use. I also found some others but each had its own strange
behavior wich i really didnt liked.
So i decided to make a simple own one. But i came to the point where in
example a user enter some letters
in a short time, and my div wich comes up starts flickering and fading
out as many times as the user entered a letter.
So i need a kinda of delay. And thats the point i dunno how to solve
this. I've tried to inspect other solutions but
i dont get it how they made it. My JS skills are probably to poor :) (i
come from perl)
So any suggestions or help would be wonderful.
Thx in advance,
Ralf
----------------------------------------------------------------------------------
function search_tips(id,indicator,resultdiv,script,obj){
// If the result div isnt completly hidden return.
// this prevents flickering !!!...or not :( - need a delay of <input>
if($("#"+resultdiv).css("display") == 'block'){
return;
}
var postvalue; // Define a variable
postvalue = $("#"+id).val(); // fetch the text entered in the inputbox
$("#"+indicator).show(); // while loading show it to user
// now make the Ajax-call to the passed script
jQuery.ajax({
type: "POST",
url: script,
data: "keyword=" + postvalue,
datatype: 'html',
success: function(obj){ $("#"+resultdiv).html(obj);
$("#"+resultdiv).fadeIn("slow");},
error: function(obj){ alert("Error while calling " + script); }
});
// After Loading of Data is finished, instantly hide the div which
showed the loading animation
$("#"+indicator).css("display","none");
// Bind the onBlur to the div and fade it out after loosing focus
$("#"+ $(obj).id()).oneblur( function(){
$("#"+resultdiv).fadeOut("normal"); } );
}
-----------------------------------------------------------------------------------
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/