Greetings!
I've been fooling around with HAML and converted a few view partials from .erb
to .haml
. But when i tried to convert .js.erb
view, it just wont execute. E.g. seems my .js.haml
is not executed while .js.erb
works as it should be.
Here's my .js.erb
(which works as well):
<% if @quote.errors.any? && @quote.approved? %>
$("#data_form").html("<%= escape_javascript(render(:partial => "form")) %>");
<% else %>
$("#data_grid").prepend("<%= escape_javascript(render :partial => "quote", :locals => { :quote => @quote }) %>");
$("#quote_author,#quote_body").each(function(i,e) {
$(this).val("");
});
<% end %>
And here's what i'm replacing it with:
-if @quote.errors.any? && @quote.approved?
$("#data_form").html("#{escape_javascript(render(:partial => "form"))}");
-else
$("#data_grid").prepend("#{escape_javascript(render :partial => "quote", :locals => { :quote => @quote })}");
$("#quote_author,#quote_body").each(function(i,e) {
$(this).val("");
});
What's the problem and how to solve it?
Try:
-if @quote.errors.any? && @quote.approved?
:plain
$("#data_form").html("#{escape_javascript(render(:partial => "form"))}");
-else
:plain
$("#data_grid").prepend("#{escape_javascript(render :partial => "quote", :locals => { :quote => @quote })}");
$("#quote_author,#quote_body").each(function(i,e) {
$(this).val("");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With