开发者

How do you access a JavaScript variable inside a Rails escape_javascript line?

开发者 https://www.devze.com 2023-03-15 14:54 出处:网络
Say I\'m inside a JavaScript function, I\'d like access to data within the Rails line like this: var DATA_USED

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消