我想在使用Rails的Ajax中顯示Flash的錯誤消息,但它沒有顯示它,並且我嘗試了幾種方法來做到這一點,但我不能修正它。我怎樣才能在rails中顯示ajax的錯誤
這裏是我的形式來顯示我的錯誤:
#flash-error.flash-error{:style => "display: none"}
#flash-notice.flash-info{:style => "display: none"}
%h3 New Document
- form_for(:repo_document, :url => {:all_categories => @repo_categories, :action => "create", :format => "js", :query => params[:query]}, :html => { :id => "repo_document_form", :multipart => true, :target => 'upload_frame'}) do |form|
這裏是控制器:
if !params[:stands]
respond_to do |format|
format.js do
responds_to_parent do
render :update do |page|
page.show "flash-error"
page.replace_html "flash-error","Please select stands you want to grant permission to view this stand."
end
end
end
return
end
end
我在做什麼錯?
在發佈之前,你應該多做一些診斷 - 確保你點擊了format.js塊,並嘗試在iframe中顯示flash,以確保它不是一個responds_to_parent錯誤。 – klochner 2009-08-31 16:42:06