简体   繁体   English

Ruby on Rails将JavaScript变量添加到link_to url参数

[英]Ruby on rails add javascript variable to link_to url params

I have a javascript variable, I would to send along with my params when a person clicks a link. 我有一个javascript变量,当有人单击链接时,我将与我的参数一起发送。

var js_variable = something;
...
<%= link_to_remote "Link Name", {:url => {url_params}, ajax_options}, {html_options} %>

how do I add js_variable to the url_params hash?? 如何将js_variable添加到url_params哈希?

Using rails 2.3.8 使用滑轨2.3.8

possibly this older question will be useful to you Rails3 - How to send Javascript Variable to a controller's action with the link_to helper? Rails3-如何使用link_to帮助程序将Javascript变量发送到控制器的动作,可能对您有用

But it seems to me you should be using link_to_function and change the href at runtime 但是在我看来,您应该使用link_to_function并在运行时更改href

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM