Cannot revalidate without bLazy crashing
rmcauley opened this issue · 4 comments
I'm trying to use bLazy without any libraries. When I try to revalidate, it fails, as "self" is a null value in scope.revalidate. I don't see self being defined in a scope that's useable inside revalidate.
Should it be initialize(scope) instead of initialize(self) inside of revalidate? Changing that line to be initialize(scope) seems to make things work for me.
Hey @rmcauley
That sounds odd. Works fine here. Do you have a live example?
I suppose you mean "this" instead of "self" because it's "this" that is passed in the initialize call:
scope.revalidate = function() {
initialize(this);
};
Yes, sorry, that's what I meant.
It's happening to me because I'm calling revalidate on a setTimeout without wrapping it in a function or using .bind.
Live example:
Yes I see. When you pass setTimeout a reference like you do, "this" is window but if you instead pass an eval string or an anonymous function it works.
// anonymous function
setTimeout(function(){ bLazy.revalidate(); }, 300);
// eval string (not recommended)
setTimeout("bLazy.revalidate()", 300);
Closing due to edge case. This should not be needed anymore after v.1.5.4 (https://github.com/dinbror/blazy#v-154-20160306)