Rails 2 到 Rails 3:使用 link_to 而不是 link_to_remote(包括远程和更新) [英] Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)

查看:28
本文介绍了Rails 2 到 Rails 3:使用 link_to 而不是 link_to_remote(包括远程和更新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定,这是一个快速而简单的答案.我正在将 Rails 项目从版本 2 升级到版本 3,并根据 Rails 3 更新用 link_to 替换 link_to_remote 的负载.甚至像这样简单的事情:

A quick and easy answer I'm sure. I'm upgrading a Rails project from version 2 to version 3 and replacing a load of the link_to_remote with link_to's as per the Rails 3 update. Even something as simple as :

<%= link_to "Check Time",
        {:action=>:get_time}, :remote=>true, :update=>'current_time' %>
<div id='current_time'></div>

似乎不起作用.请求(使用 get 方法)正在通过,并且呈现的 html 是:

doesn't seem to work. The request (using get method) is going through ok and the rendered html is :

<a href="/monitoring/get_time" data-remote="true" update="current_time">Check Time</a> 

Routes.rb 条目:

Routes.rb entry :

get "monitoring/get_time"

正如我所说,我确信这对我来说是一个非常明显的问题!

As I say I'm sure this is a very obvious issue on my part!

推荐答案

新的 link_to :remote => 不支持 :update 选项真的.

The :update option isn't supported by the new link_to :remote => true.

你要么必须

  • 使用传统插件
  • 自己编写 JS/AJAX,而不是使用 :remote =>真的
  • 使用 render :update { |page|p.replace_html ... }

这篇关于Rails 2 到 Rails 3:使用 link_to 而不是 link_to_remote(包括远程和更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆