How do you access a JavaScript variable inside a Rails escape_javascript line?
Say I'm inside a JavaScript function, I'd like access to data within the Rails line like this:
var DATA_USED
html = "<%= e开发者_JS百科scape_javascript(render :partial => 'change_date_range', :locals => {:end_date_string => DATA_USED }) %>";
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.
精彩评论