我有我的视图页面上的按钮,只要其获得点击,会出现一个弹出式模态...现在我想关闭该模式......我怎样才能关闭模式弹出窗口的jQuery
这里是我的代码
function openSirenModal() {
var timeout;
var progress;
var status;
$.modal({
contentAlign: 'center',
width: 240,
title: 'Loading',
content: '<div style="line-height: 25px; padding: 0 0 10px"><span id="modal-status">Contacting to the device...</span><br><span id="modal-progress">0%</span></div>',
buttons: {},
scrolling: false,
actions: {
'Cancel': {
color: 'red',
click: function (win) {
win.closeModal();
}
}
},
onOpen: function() {
// Progress bar
var progress = $('#modal-progress').progress(100, {
size: 200,
style: 'large',
barClasses: ['anthracite-gradient', 'glossy'],
stripes: true,
darkStripes: false,
showValue: false
}),
// Loading state
loaded = 0,
// Window
win = $(this),
// Status text
status = $('#modal-status'),
// Function to simulate loading
simulateLoading = function() {
};
// Start
//timeout = setTimeout(simulateLoading, 2500);
},
onClose: function() {
// Stop simulated loading if needed
clearTimeout(timeout);
}
});
var siren = "siren";
$.ajax({
type: "POST",
data: {
value: siren
},
url: "http://localhost/siren/siren/",
success: function (data) {
alert(data);
if (data == 1) {
var auto_refresh = setInterval(
function() {
$.get('siren/sirenjson', function (datas) {
if (datas == 1) {
$('#modal-progress').hideProgressStripes().changeProgressBarColor('green-gradient');
$('#modal-status').text('success!');
setTimeout(function() {
clearInterval(auto_refresh);
win.closeModal();//here i want to close the popup modal
}, 1500);
}
});
}, 1000);
} else {
}
//clearTimeout(timeout);
},
error: function() {
alert("error");
progress.hideProgressStripes().changeProgressBarColor('red-gradient');
setTimeout(function() {
win.closeModal();
}, 1500);
status.text('error!');
}
});
};
我写代码win.closeModal();但它不工作,因为我不能访问取胜变量setInterval..i不知道我怎样才能访问它
你想使用closeModal(); ...或者你也关闭通过增加接近股利情态 –
我只是想关闭关闭模态..如果我不使用设置间隔,然后它的作品,否则它不会 – hellosheikh
以及我只是想关闭模式..如果我没有指定时间间隔,那么我可以关闭它..但在间隔时间它不工作 – hellosheikh