Cannot revalidate without bLazy crashing #73

Closed
rmcauley opened this Issue Jan 12, 2016 · 4 comments

Projects

None yet

2 participants

@rmcauley

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.

@dinbror
Owner
dinbror commented Jan 13, 2016

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);
};
@rmcauley

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:

http://rainwave.cc/~rmcauley/blazy/

@dinbror
Owner
dinbror commented Jan 14, 2016

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);
@dinbror
Owner
dinbror commented May 28, 2016

Closing due to edge case. This should not be needed anymore after v.1.5.4 (https://github.com/dinbror/blazy#v-154-20160306)

@dinbror dinbror closed this May 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment