How to render partial in page from rails controller without prototype helpers
I'm remov开发者_如何学Going Prototype from my Rails 3 app in exchange for jQuery and trying to figure out how my controller should update part of the html page without using this Prototype helper:
page.replace_html( "content", :partial => "day" )
Since you've upgraded to Rails 3, you're on a great track to also stop using RJS. Use callbacks on the AJAX method to do the replacing. For example:
Ajax call:
$.ajax(
  url: "/things/one",
  type: "GET",
  complete: function(response, status) {
    $('#content').html(response);
  }
);
Then in the controller:
class ThingsController
  def one
    respond_to do |format|
      format.js { render :partial => "day" }
    end
  end
end
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论