0

Say I'm inside a JavaScript function, I'd like access to data within the Rails line like this:

var DATA_USED
html = "<%= escape_javascript(render :partial => 'change_date_range', :locals => {:end_date_string => DATA_USED }) %>";
1
  • I'm afraid this doesn't make much sense. The JavaScript code runs in the client browser, and there'll be no trace of the Rails code there; it's all run on the server. Commented Jun 27, 2011 at 21:12

1 Answer 1

2

You really should use AJAX (I recommend jQuery) for this. You'll want to have JS send a request back to your Rails server with the JavaScript variable as a param in the request.

Sign up to request clarification or add additional context in comments.

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.