问题描述
我在做一个教程轨动画加载页面但问题是,我收到以下消息的未定义的方法`remote_function .I've做了一些研究,似乎remote_function是德precated.Can人请告诉我如何我做在轨道上3.1 code的工作:
I'm doing a tutorial for rails animated loading page but the problem is that I get the following message undefined method `remote_function'.I've done some research and it seems that "remote_function" is deprecated.Can anyone tell me please how to I make the code work on rails 3.1 :
onload="<%= remote_function(:url => { :action => :get_content_to_display } ) %>"
感谢您的帮助。
推荐答案
3.1的Rails prefered使用不引人注目的JavaScript。所以,你应该使用JavaScript框架(为前。JQuery的),以实现自己的目标。
在旧版本的Rails的 remove_function
刚刚发送Ajax请求的服务器时,它被调用。
所以,你可以做这样的事情:
Rails 3.1 prefered to use unobtrusive javascript. So you should use javascript framework (for ex. JQuery) to achieve your goal.In old version of Rails remove_function
just sent AJAX request to server when it was called.So you can do something like this:
$(document).ready ()->
$.get "your_url", ()->
#handle response
希望这会帮助你。这里是一些额外的信息:
这篇关于remote_function替代在轨3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!