Reputation: 5947
i'm trying to refresh the page after the loop is finished. this my example doesn't work where i'm doing mistake?
if(this.vpb_browsed_files.length > 0) {
for(var k=0; k<this.vpb_browsed_files.length; k++){
var file = this.vpb_browsed_files[k];
this.vasPLUS(file,0);
if (parseInt(k) == parseInt(this.vpb_browsed_files.length)) {
var refresh = true;
} else {
var refresh = false;
}
}
if (refresh) {
window.location.reload();
}
}
Upvotes: 0
Views: 1281
Reputation: 43850
You are kinda doing a lot of redundant things:
if(this.vpb_browsed_files.length > 0) {
for(var k=0; k<this.vpb_browsed_files.length; k++){
var file = this.vpb_browsed_files[k];
this.vasPLUS(file,0);
}
window.location.reload();
}
You don't need to do parseInt(k)
because the variable is already and integer. The same goes for this.vpb_browsed_files.length
Upvotes: 3