开发者

Equivalent to remote_function using jquery and jquery-rails

开发者 https://www.devze.com 2023-02-07 05:22 出处:网络
I am building an app in Rails 3.0.3 and Ruby 1.9.2. I have installed the jquery-rails gem and use jquery instead of prototype. I have a .js.erb will update the contents of the div tag but I need to ca

I am building an app in Rails 3.0.3 and Ruby 1.9.2. I have installed the jquery-rails gem and use jquery instead of prototype. I have a .js.erb will update the contents of the div tag but I need to call a function in the controller to get updated information for the div tag. Can someone provide an example or point me to one? I have tri开发者_开发技巧ed the railscasts unobtrusive javascript tutorial but I can not get is to work for my situation.


See How to make Ajax calls with Rails 3 using remote_function? and my comment there. The answer of Ibz, adding :remote, only makes sense for form elements and even then is only a part of the story.


In Rails 3 all the remote_methods helpers have been removed. To make them work with AJAX, simply pass the :remote => true option to the original non-remote method.

Reference: Unobtrusive JavaScript in Rails 3

0

精彩评论

暂无评论...
验证码 换一张
取 消