我正在尝试将带有 link_to_remote 调用的字符串作为 :id 传递,并且该字符串应该从输入字段中收集,其 id 为“movie_title”。
<div id="search_list">Nothing here yet</div>
<br />
<% semantic_form_for @movie do |f| %>
<% f.inputs do -%>
<%= f.input :title, :class => "movie_title" %> <%= link_to_remote( 'Search...', { :url => { :action => :imdb_search, :id => "'+$('\#movie_title').value+'" } }, { :title => "Search for this movie", :class => "imdb_search" } ) -%>
[...removed text that does not matter...]
<% end -%>
<%= f.buttons %>
<% end %>
我不断收到一个javascript错误,如果我从链接中的jquery中删除#,它会返回“未定义”。
我得到的链接是:
<a class="imdb_search" href="#" onclick="jQuery.ajax({data:'authenticity_token=' + encodeURIComponent('yHPHYTZsPTQLi9JYSauUYcoie/pqPPk2uHBTN0PzNsQ='), dataType:'script', type:'post', url:'/movies/imdb_search/'+$('%23movie_title').value+''}); return false;" title="Search for this movie">Search...</a>
所以我想用movie_title的内容更新链接。我怎么做?