簡體   English   中英

Ruby on rails 3: link_to:remote => true 將“remote”視為 URL 參數

[英]Ruby on rails 3: link_to :remote => true treats “remote” as a URL parameter

我想知道用於發出 ajax 請求的 link_to 語法應該是什么(或其他關於此處可能出現問題的想法)。 目前我有

<%= form_tag "save_sets", :remote => true, :name => "set_form" do %>

在一個文件中,它完美地工作。 但是,在同一個文件中,所有

<%= link_to assignment.name, :action => :view_student_problem_set, :remote => true %>
<%= link_to assignment.name, :remote => true, :action => :view_student_problem_set %>
<%= link_to assignment.name, {:action => :view_student_problem_set, :remote => true} %>
<%= link_to assignment.name, {:remote => true, :action => :view_student_problem_set} %>
<%= link_to assignment.name, {:remote => true}, {:action => :view_student_problem_set} 
<%= link_to assignment.name, {:remote => true}, :action => :view_student_problem_set %>

只需生成帶有“?remote = true”而不是data-remote =“true”的鏈接,並且

<%= link_to assignment.name, :remote => true, {:action => :view_student_problem_set} %>

顯然是語法錯誤。

我嘗試過的大多數組合都來自教程、論壇帖子和文檔。 我不認為符號的 collections 必須按特定順序排列,但我只是徹底。 無論如何,我的谷歌搜索技巧已經達到了他們的水平。

相關的 jquery 代碼、controller 代碼以及 form_tag 和 link_to 標簽之間的所有內容都是相同的。

謝謝大家。

<%= link_to assignment.name, {:action => :view_student_problem_set}, :remote => true %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM