bigloop=setInterval(function () {
var checked = $('#status_table tr [id^="monitor_"]:checked');
if (checked.index()===-1 ||checked.length===0 || ){
bigloop=clearInterval(bigloop);
$('#monitor').button('enable');
}else{
(function loop(i) {
//monitor element at index i
monitoring($(checked[i]).parents('tr'));
//delay of 3 seconds
setTimeout(function () {
//when incremented i is less than the number of rows, call loop for next index
if (++i < checked.length) loop(i);
}, 3000);
}(0)); //start with 0
}
}, index*3000); //loop period
मेरे पास ऊपर कोड है और कभी-कभी यह काम कर रहा है, कभी-कभी यह नहीं होता है। मैं सोच रहा हूँ कि अगर clearInterval वास्तव में टाइमर साफ़ करता है ?? क्योंकि यह monitorबटन है जो केवल निष्क्रिय हो जाएगा जब यह monitoringफ़ंक्शन में होगा। मेरे पास एक और हैclearIntervalजब एक तत्व .outputRemoveपर क्लिक किया जाता है होता है। नीचे दिए गए कोड को देखें:
//remove row entry in the table
$('#status_table').on('click', '.outputRemove', function () {
deleted= true;
bigloop= window.clearInterval(bigloop);
var thistr=$(this).closest('tr');
thistr.remove();
$('#monitor').button('enable');
$('#status_table tbody tr').find('td:first').text(function(index){
return ++index;
});
});
लेकिन इसे फिर से अक्षम करने से पहले इसे थोड़ी देर के लिए सक्षम किया गया था। विल clearIntervalसे कार्यक्रम बाहर निकलने के setIntervalसमारोह?
opps टाइपो। मेरे पास एक फ़ंक्शन था
—
yvonnezoe
clearloop(loopname)जिसमें clearIntervalइसे सरल बनाने के लिए था, लेकिन मैंने इसे ऊपर दिए गए कोड में सीधे बदल दिया।
loopnameदूसरे स्निपेट में है? वो क्या है?