Bind jQuery UI autocomplete using .live()

jQuery UI autocomplete function automatically adds the class “ui-autocomplete-input” to the element. I’d recommend live binding the element on focus without the “ui-autocomplete-input”
class to prevent re-binding on every keydown event within that element.

$(".foo:not(.ui-autocomplete-input)").live("focus", function (event) {
    $(this).autocomplete(options);
});

Edit

My answer is now out of date since jQuery 1.7, see Nathan Strutz’s comment for use with the new .on() syntax.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)