我正在使用 best_in_place gem (https://github.com/bernat/best_in_place) 在 Rails 应用程序中进行就地编辑。我的 Controller 有以下线路:
format.json { respond_with_bip(@user) }
gem 会为任何验证错误生成 purr 通知,但有什么方法可以让我同时显示成功更新的通知?我似乎无法在文档中的任何地方找到它,而且 bip 以 JSON 响应这一事实使整个事情在我看来非常黑箱。
任何帮助将不胜感激。
最佳答案
$('.best_in_place').best_in_place().bind('ajax:success', function(evt, data, status, xhr) {
console.dir(evt);
console.dir(data);
console.dir(status);
console.dir(xhr);
// Use them how ever you need eg $("#yourdiv").text(data["message"]);
});
在您的 Controller 中
format.json { render :json => { :message => "Successfully Saved your Model" } }
关于ruby-on-rails - Rails 'Best in Place' Gem - Flash 成功消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10489976/