2

I am not using erb, but using haml instead. So something like:

$("<%= escape_javascript(render @user) %>").appendTo("#users"); 

in http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html is not working.

Does anyone have ideas?

1 Answer 1

1

For HAML, use String interpolation as below:

$("#{escape_javascript(render @user)}").appendTo("#users");  
Sign up to request clarification or add additional context in comments.

2 Comments

should I put this in *.js.haml file? Can I use this just in *.js file?
*.js.haml file as it should be interpreted by Ruby.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.