Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot revalidate without bLazy crashing #73

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

Cannot revalidate without bLazy crashing #73

rmcauley opened this issue Jan 12, 2016 · 4 comments

Comments

@rmcauley
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
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 as completed May 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants