title: Render the Flash message through js.erb file
body: <p>In my Rails app, I want to render the flash message from my controller method <code>delete_option</code> (<code>questions_controller</code>) to a partial <code>_edit.html.erb</code> inside questions folder itself. I have a js file <code>delete_option.js.erb</code> and I could successfully render the edit using the below line to a div element with id <code>edit_subquestion</code>.</p>
  
  <pre><code>$("#edit_subquestion").html("&lt;%= escape_javascript(render(:partial =&gt; "edit")) %&gt;");
  </code></pre>
  
  <p>I put a div element inside the <code>_edit.html.erb</code> to render the flash message as given below.</p>
  
  <pre><code>&lt;div id="flash_delete_option"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I am trying to render the flash message from the method <code>delete_option</code> to the above <code>div</code> element as given below.</p>
  
  <pre><code>if((&lt;%=flash[:success]%&gt;).length &gt; 0)
      $("#flash_delete_option").html("&lt;%= escape_javascript(render('&lt;%=flash[:success]%&gt;')) %&gt;");
  </code></pre>
  
  <p>I am getting syntax errors. Please help to resolve this. Everything tried as per the answer. Not getting it.</p>