Archive

Archive for the ‘Webdevelopment’ Category

jQuery 1.3.2. autocomplete – keydown bug

February 3rd, 2010 4 comments

Not using jQuery version 1.3.2? Skip this post.

Working with the jquery autocomplete-complete plugin today made me notice the control performs some weird behavior when you try to unbind or unautocomplete.

In a nutshell: renewing the autocomplete plugin will not unbind the “keydown” event. This is actually due to a bug in jQuery 1.3.2.

What can we do about it?

  • Change your version of the jQuery plugin (1.4 fixed the “keydown” bug)
  • Or manually update the autocomplete plugin to support jQuery 1.3.2

Where can you update the autocomplete to support 1.3.2? Open your file and look for the following code:


}).bind("unautocomplete", function() {
	select.unbind();
	$input.unbind();
	$(input.form).unbind(".autocomplete");
});

Just add one line of code before the $input.unbind() method:


}).bind("unautocomplete", function() {
	select.unbind();
	$input.unbind("keydown.autocomplete");
	$input.unbind();
	$(input.form).unbind(".autocomplete");
});

Presto!

(ps: Working in Visual Studio? make sure you modify the jquery.autocomplete.min.js file, this file is used when your application runs on the webserver.)