Ruby on Rails:link_to_remote和rel

时间:2010-06-15 18:38:44

标签: ruby-on-rails

我想要一个指向remote的链接以获得rel标记,因为我想使用facebox。

我让它使用常规链接...但我需要远程链接来处理用户没有启用javascript的事件。

这个,目前不起作用(除了非javascript部分)

<%= link_to_remote "Ask a Question", 
            {:url => 
                {:action => :ask_question,
                :id => @container.id.to_s,
                :javascript_disabled => false
                }, :rel => 'facebox'},
            :href => url_for(
                            :controller => :view,
                            :action => :ask_question,
                            :id => @container.id.to_s,
                            :javascript_disabled => true) %>

1 个答案:

答案 0 :(得分:0)

link_to_remote中,您在第三个参数中传递HTML选项(如rel)。在你的代码中,你在第二个传递它(即第一个哈希)。试试这个:

<%= link_to_remote("Ask a Question", 
      { :url => { :action => :ask_question,
                  :id => @container.id.to_s,
                  :javascript_disabled => false
                }
      },
      { :href => url_for( :controller => :view,
                          :action => :ask_question,
                          :id => @container.id.to_s,
                          :javascript_disabled => true ),
        :rel => 'facebox'
      }
    )
%>

(如你所知,一些括号和花括号是可选的,但是为了清楚起见,我在这里列出了所有这些,并且可能会保留它们,因为你在这里传递了很多复杂的参数。)< / p>

相关问题