开发者

How to render partial in page from rails controller without prototype helpers

开发者 https://www.devze.com 2023-01-17 14:15 出处:网络
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:

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
0

精彩评论

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