轨道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)

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

问题描述

一个快速简便的答案,我敢肯定。 我是从第2版升级Rails项目第3版和的link_to的按在Rails 3的更新替换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更新选项:远程=&GT;真正的

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

您将不得不

  • 使用旧版插件
  • 而不是使用
  • 在写JS / AJAX自己:远程=&GT;真正的
  • 使用渲染:更新{|首页| p.replace_html ...}
  • use the legacy plugin
  • write the JS/AJAX yourself instead of using :remote => true
  • use render :update { |page| p.replace_html ... }

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

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