我使用bootstrap notify来显示保存功能。问题是,用户可以保存多个。
示例:用户单击按钮每秒(Checkbox1,Checkbox2,...)。每个复选框都会调用通知功能。
目标:对话框应显示3秒钟。如果在3秒内再次单击该按钮,则不会出现进一步的对话框。 3秒但应该从头开始(重新启动)
$(function(){
$(".btn").on("click",function(){
$.notify({
title: 'This dialog should appear only once',
icon: 'glyphicon glyphicon-star',
message: ""
},{
type: 'info',
animate: {
enter: 'animated fadeInUp',
exit: 'animated fadeOutRight'
},
placement: {
from: "bottom",
align: "left"
},
offset: 20,
spacing: 10,
z_index: 1031,
timer: 3000,
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mouse0270-bootstrap-notify/3.1.5/bootstrap-notify.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<button class="btn btn-primary">click me</button>
你可以使用onClosed事件让你知道通知何时结束,打开时可以阻止它再次打开一个标志,你可以在触发onClosed事件时更改...
$(function(){
var busy = false;
$(".btn").on("click",function(){
if(!busy) {
busy=true;
$.notify({
title: 'This dialog should appear only once',
icon: 'glyphicon glyphicon-star',
message: ""
},{
type: 'info',
animate: {
enter: 'animated fadeInUp',
exit: 'animated fadeOutRight'
},
placement: {
from: "bottom",
align: "left"
},
offset: 20,
spacing: 10,
z_index: 1031,
timer: 3000,
onClosed: function() {
busy=false;
}
});
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mouse0270-bootstrap-notify/3.1.5/bootstrap-notify.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<button class="btn btn-primary">click me</button>