Scenario is that I have written a function for auto refresh on form element and I want onclick event on login button to disable the auto refresh function.
I'm not able to get disable the autorefresh and the page still refreshes.
My code is:
$('#form').ready(function () { //Increment the idle time counter every minute.
var idleInterval = setInterval("timerIncrement()", 15000); // 1 minute
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e){
idleTime = 0;
});
});
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 2) { // 20 minutes
window.location.reload();
}
}
$('#login').ready(function () {
alert("working promptly");
//Zero the idle timer on mouse movement.
$(this).click(function (e) {
alert("Hi In click !");
$('#form').attr("disabled","true");
});
});
I guess you are needing to clear the interval timer:
$(this).click(function (e) {
alert("Hi In click !");
$('#form').attr("disabled","true");
clearInterval(idleInterval);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With