3
我是新來的紅寶石在軌道上。我正在學習一個教程,以瞭解ajax如何在使用link_to和remote = true的rails上工作。我有以下代碼。ajax,link_to遠程紅寶石在軌道上
// in view/home/sample.html.erb
<head> <%= javascript_include_tag "prototype.js" %> </head>
<body>
<div id="time_div">
<%= link_to("click here", :update=>'time_div' ,:url=>{:action => :say_when} , :remote => true) %>
</div>
</body>
// in /controllers/home_controller.rb
def sample
end
def say_when
render_text "<p>The time is <b>" + DateTime.now.to_s + "</b></p>"
end
我把prototype.js放在assets/javascripts文件夾中。 但我沒有得到瀏覽器的時間。 PLZ有人幫助
嘿,謝謝它的工作。問題也出現在link_to語法中。我將它改爲<%= link_to(「click here」,:action =>:say_when,:remote => true)%>。現在它的作品! – nbbk 2013-03-17 19:05:34