Rails 3 is javascript escaping in .js.erb file

I have the following in the .js.erb file returned after submitting form c remote: true.

create.js.erb

$("#flash-notices").html(" <%= escape_javascript(render(partial: "/shared/flash_messages", locals: { form_errors: @artist.errors.full_messages } )) %> ");
$("#flash-notices").fadeIn(300).delay(3000).fadeOut(300);
...

However, what returns to the browser is:

<textarea data-type="text/javascript" response-code="200">  
$(&quot;#flash-notices&quot;).html(&quot;   &lt;ul&gt;\n            &lt;div class=\&quot;alert alert-success\&quot;&gt;\n               &lt;li class=\&quot;alert-item\&quot;&gt;Artwork saved&lt;\/li&gt;\n            &lt;\/div&gt;\n &lt;\/ul&gt;\n &quot;);
  $(&quot;#flash-notices&quot;).fadeIn(300).delay(3000).fadeOut(300);
...
</textarea>

How can I stop the first level of JS escaping that stops jQuery execution?

+3
source share

All Articles