Reputation: 27114
Here's my biopsis
Works :
:plain
console.log("#{escape_javascript(render(@job_charge).html_safe)}");
Does not work ( but should? ) :
:plain
console.log("#{j render(@job_charge).html_safe }");
Upvotes: 1
Views: 595
Reputation: 5908
j
is, indeed, shorthand for escape_javascript
according to the docs: http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-j
I use it all the time and it works.
Upvotes: 0
Reputation: 13877
j
is shorthand for json_escape
.
escape_javascript
also exists (at least in rails 3.x) but does something different - it escapes strings for use inside javascript string literals.
I guess the first sample is failing for a different reason. Check your log!
Upvotes: 1
Reputation: 11710
It looks like j
is actually shorthand for json_escape
, not escape_javascript
.
http://api.rubyonrails.org/classes/ERB/Util.html
Upvotes: 4