I have this following code in in jquery.
$(document).ready(function () {
console.log('Hello');
var uploadButton = $('#upload-button');
uploadButton.on('click', function () {
uploadButton.unbind('click');
progressBar();
uploadButton.bind('click');
});
});
function progressBar(){
var element = document.getElementById('bar');
var width = 1;
var id = setInterval(addFrame, 25);
function addFrame() {
if(width == 100){
clearInterval(id);
element.style.width = 0;
return true;
}
width += 1;
element.style.width = width + '%';
}
}
What I'm trying to do is to call a function for a progress bat when an HTML button
item is being pressed, but also try to disable anymore calls until the current call is finished. By initial idea was to unbind the click
event when it is being pressed, execute the function, and then bind click
again to the same element, but so far, the only thing I get is only one call of progressBar
and after that, the button
remains unbound for click
.
What am I doing wrong?
Thank you.