Skip to content

Instantly share code, notes, and snippets.

@uhhuhyeah
Created April 8, 2011 18:21
Show Gist options
  • Save uhhuhyeah/910426 to your computer and use it in GitHub Desktop.
Save uhhuhyeah/910426 to your computer and use it in GitHub Desktop.
Work around for select not working in laktek / jQuery-Smart-Auto-Complete in IE browsers
// Where 'fruits_field' is the id of the autocomplete field
// Note: Place this code after the smartAutoComplete() function
$('input#fruits_field').bind({
lostFocus: function(e) {
// Grab any highlighted results
results = $('.smart_autocomplete_highlight');
if (results && $(results[0]).text() != '') {
// Set the input's value to the selected result
$('input#fruits_field').val($(results[0]).text());
// Your code for dealing with a selected suggestion
// ...
// Prevent default otherwise all is for nowt
e.preventDefault();
// Get rid of the results drop down
$('.smart_autocomplete_container').hide();
};
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment