I can't seem to get autocomplete working with forms that I'm adding to the screen with javascript. For example, I am using my new route to render my object's form. Inside my new.js.erb in rails file I have the following:
$("div#container").hide().html("<%= escape_javascript render 'form' %>").fadeIn();
Once rendered, if I type into my input element:
<input id="object_name" name="object[name]" placeholder="Name" size="30" type="text">
And listen with it with javascript:
jQuery ->
$('input#object_name').autocomplete
source: ['Test', 'Testing', 'Test 234']
I get nothing as far as autocomplete is concerned. If I copy and paste this form though and have it on the screen at load (and not added dynamically with my rails new path) it will work fine. How do I get autocomplete to listen to things that are added dynamically?