I'm trying to make a plugin JSLint proof and am struggling with the following error message:
Don't make functions within a loop.
which complains about this snippet:
for ( i = 0; i < pops.length; i++){
pops.eq(i)
.addClass('reverse out '+trans)
.hide('fast')
.removeClass('ui-panel-active')
.find(".ui-page-active")
.not("div:jqmData(show='first')")
.removeClass('ui-page-active').end()
.find(".ui-btn-active")
.removeClass('ui-btn-active').end()
.find('div:jqmData(external-page="true")')
.remove().end().end()
.delay(350)
// the problem
.queue(function(next){
$(this).removeClass('reverse out pop slide');
next();
});
...
}
I understand where the problem is, but no idea how to make it JSlint-compliant.
Question:
How do I get the function out of the loop?
Thanks!