ruby on rails - How to appending a Form_For block to a Target div with in coffe.erb file? -
here want accomplish:
- let user enter home address via form
- return results ajax call on page
- have button on each result allows me save attribute of home @home object via remote call.
i appending results of ajax call <div id="search-results">
. within div have link looks <a href="#9090090"> home id </a>
. when user clicks link want create new instance of home model :alt_home_id => 9090090
(which href attribute text of link). these links being appended in coffee.erb file:
if results.home_id? targetdiv.append '<a href="#9090090"> home id </a>'
i tried doing this:
searchresults.append '<%= form_for property.new, |f| %> <%= f.text_field :alt_home_id %> <%= f.submit %><% end %>'
without line breaks of course.
this gives me error of unexpected keyword_do_block
is best way create 1 new object 1 attribute being created. have considered writing ajax call grab id , create new 1 way. unsure how structure on page loading these things dynamically.
thanks in advance.
you have remove comma before do
Comments
Post a Comment