Bind jQuery UI autocomplete using .live()

autocomplete, binding, jquery

Solution

If you are using the `jquery.ui.autocomplete.js` try this instead

.bind("keydown.autocomplete") or .live("keydown.autocomplete")

if not, use the `jquery.ui.autocomplete.js` and see if it'll work

If that doesn't apply, I don't know how to help you bro

Problem

I've searched everywhere, but I can't seem to find any help... I have some textboxes that are created dynamically via JS, so I need to bind all of their classes to an autocomplete. As a result, I need to use the new .live() option. As an example, to bind all items with a class of .foo now and future created: ``` $('.foo').live('click', function(){ alert('clicked'); }); ``` It takes (and behaves) the same as .bind(). However, I want to bind an autocomplete... This doesn't work: ``` $('.foo').live('autocomplete', function(event, ui){ source: 'url.php' // (surpressed other arguments) }); ``` How can I use .live() to bind autocomplete? UPDATE Figured it out with Framer: ``` $(function(){ $('.search').live('keyup.autocomplete', function(){ $(this).autocomplete({ source : 'url.php' }); }); }); ```

Original source