Best practices for loading page content via AJAX request in Rails3?

后端 未结 4 476
醉酒成梦
醉酒成梦 2021-01-31 21:35

Suppose you have a page with two columns of content. For whatever reason, you wish to retrieve the HTML content of one of those columns after the page has loaded, via an AJAX re

4条回答
  •  孤街浪徒
    2021-01-31 21:42

    There is a simple way ofcource, just add respond_to :html, :js to your controller and create *.js.erb views in your app/views/ directory. Your controller will then be able to respond to javascript format and you can write javascript with ruby code in *.js.erb files.
    Check this out: Unobtrusive javascript in Rails 3

提交回复
热议问题