我正在使用link_to:remote来更新HTML上的div
元素之一。这只是一个初学者的代码。但是,点击链接时不会发生更新。下面是代码:使用link_to问题:远程 - Rails 3
class SampleController < ApplicationController
def updater
render :text => Time.now
end
end
这是list.html.erb:
<script type = "text/javascript" src = "/javascripts/prototype.js">
<%= link_to "Hello Testing",
:update => "test_id",
:url => {:action => 'updater'},
:remote => true
%>
<div id="test_id"></div>
于是就点击链接 “您好测试”,在浏览器的网址更改为: http://localhost:3000/samples?remote=true&update=response_id&url[action]=updater
但是,我试图设置为当前时间的div
元素不会在UI上发生。这里可能是什么问题?
更新了帖子:
的routes.rb:http://pastebin.com/wmKsa1DD 生成的HTML代码:在Firebug http://pastebin.com/stU3FpL8 HTML响应:http://pastebin.com/WjsB7zAh
使用url_for
不会改变的行为。
看起来好像没有创建正确的链接。你检查了链接生成的html代码吗? – 2011-04-14 06:43:30
显示您的路线样本资源 – fl00r 2011-04-14 07:45:30
这是因为:URL选项没有意义link_to:http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to – 2011-04-14 08:01:00