I need to find a way to attach a jQuery autocomplete handler on to an input field that is rendered as part of an eco template.
Here's what works fine when the input field is on the page in the markup
HTML:
<input type="text" name="thing[name]" value="" id="the_input_field">
<input type="hidden" name="thing[id]" value="" id="the_id_field">
Coffee:
$("#the_input_field").autocomplete
source: "/path_to/suggest"
select: ( event, ui ) ->
$( "#the_id_field" ).val ui.item.id
I have tried a version that used a setTimeout to apply the autocomplete 3 seconds later which worked but I know this is NOT the solution, just tracking down the issue. What I need is a callback to pass into render so it can attach the autocomplete when it's done.
Hope someone can shed some light on this.
Cheers