0

I have an instance variable @foo in my create controller action and I am rendering create.rjs template. In the RJS template I need to call a js function (with page.call) and pass @foo as params. How is it possible..

2 Answers 2

1

It's been years since i've used RJS, but this might work:

page.call "your_function(#{ escape_javascript(@some_instance_var) })"
Sign up to request clarification or add additional context in comments.

Comments

1

Check out the gem gon. I am using it to pass rails variables to my javascript code.

Comments

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.