简体   繁体   English

如何在没有原型助手的情况下从rails控制器渲染局部页面

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

我正在从我的Rails 3应用程序中删除Prototype以换取jQuery并试图弄清楚我的控制器应如何在不使用此Prototype帮助程序的情况下更新部分html页面:

page.replace_html( "content", :partial => "day" )

Since you've upgraded to Rails 3, you're on a great track to also stop using RJS. 由于您已升级到Rails 3,因此您也可以停止使用RJS。 Use callbacks on the AJAX method to do the replacing. 使用AJAX方法上的回调来进行替换。 For example: 例如:

Ajax call: Ajax调用:

$.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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM