[英]Render partial after ajax call without rails helpers (using webpack)
[英]How to render partial in page from rails controller without prototype helpers
我正在從我的Rails 3應用程序中刪除Prototype以換取jQuery並試圖弄清楚我的控制器應如何在不使用此Prototype幫助程序的情況下更新部分html頁面:
page.replace_html( "content", :partial => "day" )
由於您已升級到Rails 3,因此您也可以停止使用RJS。 使用AJAX方法上的回調來進行替換。 例如:
Ajax調用:
$.ajax(
url: "/things/one",
type: "GET",
complete: function(response, status) {
$('#content').html(response);
}
);
然后在控制器中:
class ThingsController
def one
respond_to do |format|
format.js { render :partial => "day" }
end
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.