1
我希望有一種清理方式可以讓使用React的Flash消息在ajax調用中工作。一直looking on the web,說實話,我相信它可以完成沒有太多的代碼。Rails使用AJAX請求進行閃存,而不刷新頁面
def my_method
[...]
flash[:success] = "Yea bouy."
if request.xhr?
render :json => {
:order => true,
}
end
end
我沒有做頁面重定向,想知道如何得到一個簡單的Flash顯示。顯示添加更多方法的Anwers。我可以在我的方法中使用Flash代碼嗎?喜歡的東西:
def my_method
[...]
if request.xhr?
render :json => {
:order => true,
}
end
return flash[:success] = "Yea bouy." # Only works when page refreshes.
end
那麼這是唯一的方法? – Sylar
我想是的,那是唯一的方法! – RSB