开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜