I know this has been asked and re-asked, but I'm just not able to nail it.
I have a view that renders a form from a partial
.myform
= render "someform"
Here is the form
= simple_form @object, remote: true do |f|
= f.input :field1
= f.input :name, as: :autocomplete
= f.submit
Not doing any fancy rendering in the controller, it just rendering the js view as the form was submitting using remote: true
So it calls object.js.haml
:plain
$("form.new_object").html("#{escape_javascript(render(:partial => '/objects/someform'))}");
Essentially, I'm just replacing the form with a new
object.
The trouble is, and you JS-heads will see where I'm going with this, it's no longer tied to the DOM, which means other javascript events are not firing, in this case, typeahead (which is using the simple form input called autocomplete).
So, how can I re-render the someform
partial and making sure new input's are tied to js typeahead events?