flash方法仅在页面重新加载后显示消息...如何在我使用时显示该消息:remote =>真?
答案 0 :(得分:2)
如果您正在使用:remote =>你实际上是在做Ajax请求。 在这种情况下,闪光灯将无法工作。
你需要的是拥有一个模仿flash消息的js函数。
我通常都有:( Mootools,但你可能会得到这个想法)
showMessage: function(message, style, addReload)
{
var class_name = style + "_message message";
var flash = $("flash_message");
if (flash) {
flash.dispose();
}
flashElement = new Element("div", {
id: 'flash_message'
});
flashElement.set('class', class_name);
var strong = new Element('strong', {
html: message
});
if(addReload)
{
strong.adopt(
new Element("a", {href: window.location, html: 'Reload'})
);
}
flashElement.adopt(
strong
);
flashElement.inject($("mainPageContainer"));
Site.show_message();
},
每当我使用:remote =>是的,我在js视图中有这个
<% flash.discard %>
Dashboard.showMessage('Comment added and was sent to clients', 'notice');