自动关闭引导警报在 Rails 中停止工作
Auto Dismiss Bootstrap Alert stopped working in Rails
我使用以下代码在我的Ruby on Rails应用程序中自动消除成功警报:
$ ->
flashCallback = ->
$(".alert-success").fadeOut()
$(".alert-success").bind 'click', (ev) =>
$(".alert-success").fadeOut()
setTimeout flashCallback, 3000
相关警报行为:
<div class="alert alert-<%= name.to_s == "notice" ? "success" : "danger" %> alert-dismissable">
一切都很好,但似乎在途中的某个地方坏了。
我的所有代码都可以在这里找到:https://github.com/vroomanj/updemo
有没有更好的方法来完成我想完成的事情?有没有人看到我正在做的事情有什么问题,可能导致它停止工作?我希望我能说它何时停止工作,但我刚刚注意到。
使用 Noty http://ned.im/noty/#/about
这就是我使用它的方式
将此代码添加到应用程序.js.coffee
window.show_notification = (text, type)->
n = noty({
layout: 'topRight'
text: text
type: type
theme: 'relax'
animation:
open: "animated bounceInRight"
close: "animated fadeOut"
})
setTimeout (->
n.close()
), 5000
我的 Flash 消息部分采用纤薄格式
javascript:
if(#{flash[:notice].present?}){
show_notification("<span class= 'fa fa-check-circle'></span> #{flash[:notice]}", 'success')
}
if(#{flash[:alert].present?}){
show_notification("<span class= 'fa fa-exclamation-circle '></span> #{flash[:alert]}", 'error')
}
相关文章:
- jQuery UI自动完成突然停止工作
- JavaScript打印功能使日历停止工作
- 下拉列表在使用z索引放置在前面后停止工作
- 由于响应中不存在“Access Control Allow Origin”标头,跨域请求停止工作
- 注入工厂时,Angular停止工作
- React Native DeviceEventEmitter键盘WillShow停止工作
- JavaScript在更改css时停止工作
- Chrome地理定位在更新后停止工作
- 重新启动jquery脚本后,角度停止工作
- twitter引导崩溃在第一次点击后停止工作
- 更新Wordpress和我的平滑滚动停止工作
- Hammer.js过了一段时间就停止工作了
- 应用程序在“关闭”之后停止工作(控制台中没有错误);咕哝的构造”;
- Rails 3.2.3 JavaScript 突然停止工作
- 自动关闭引导警报在 Rails 中停止工作
- Rails / jQuery / Modal forms -缓存问题?有时它们就停止工作了
- 当使用javascript验证输入字段时,提交按钮在rails中停止工作
- 是什么导致Rails 3.1〃=需要jquery";停止工作
- Rails 4.2.0 app: delete link javascript停止工作
- Rails 4-JavaScript停止工作,get:undefined不是一个函数