Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to appending a Form_For block to a Target div with in coffe.erb file?
    primarykey
    data
    text
    <p>Here is what I want to accomplish:</p> <ol> <li>Let user enter an home address via a form</li> <li>Return the results from an ajax call on the page</li> <li>Have a button on each result that allows me to save an attribute of that home to a @home object via a remote call.</li> </ol> <p>I am currently appending the results of the ajax call to a <code>&lt;div id="search-results"&gt;</code>. Within that div I have a link that looks like this <code>&lt;a href="#9090090"&gt; Home ID &lt;/a&gt;</code>. When the user clicks the link I want to create a new instance of the Home model with a <code>:alt_home_id =&gt; 9090090</code> (which is the href attribute text of the link). Currently these links are being appended like so in my coffee.erb file:</p> <pre><code>if results.home_id? then targetDiv.append '&lt;a href="#9090090"&gt; Home ID &lt;/a&gt;' </code></pre> <p>I tried doing something like this:</p> <pre><code>searchresults.append '&lt;%= form_for Property.new, do |f| %&gt; &lt;%= f.text_field :alt_home_id %&gt; &lt;%= f.submit %&gt;&lt;% end %&gt;' </code></pre> <p>Without the line breaks of course.</p> <p>This gives me an error of unexpected keyword_do_block</p> <p>Is this even the best way to create just one new object with only one attribute being created. I have also considered just writing ajax call to grab the id and create a new one that way. But I am unsure how to get the structure that on the page as I am loading these things up dynamically.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload