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

Falsey values do not trigger subview's waitFor condition #137

Open
bryanspears opened this issue Jul 17, 2015 · 5 comments
Open

Falsey values do not trigger subview's waitFor condition #137

bryanspears opened this issue Jul 17, 2015 · 5 comments

Comments

@bryanspears
Copy link
Contributor

My specific example is a 'number' type where the incoming JSON value is a numeric 0. Doesn't trigger the subview render.

After some testing, this affects ALL falsey values I've tried. So a boolean field with an incoming value of false will not trigger the waitFor. Null/undefined, I can understand the reason not to have those function, but boolean false and numeric 0 are very valid use cases.

@pgilad
Copy link
Member

pgilad commented Jul 18, 2015

Yep... this is the problematic line:
https://github.com/AmpersandJS/ampersand-view/blob/master/ampersand-view.js#L301

Should waitFor only be triggered for non-null or undefined values or do we have more in the list?

P.S - This is a breaking change

@kamilogorek
Copy link
Contributor

Yes, we should probably be just more explicit about those checks.

@bryanspears
Copy link
Contributor Author

This hack has worked for me thus far. Any issues with this? If not, I could whip up a PR soon.

waitFor = getPath(this, opts.waitFor);
if (!opts.waitFor || waitFor || (waitFor !== undefined && waitFor !== null)) {

bryanspears added a commit to bryanspears/ampersand-view that referenced this issue Jul 22, 2015
bryanspears added a commit to bryanspears/ampersand-view that referenced this issue Jul 22, 2015
@bryanspears
Copy link
Contributor Author

So how would you wait for collections to be populated? If you waitFor: 'model.collection.length that would work in the current code, however, what if the collection truly has no models? Any ideas how to correctly waitFor a collection?

@cdaringe
Copy link
Member

@bryanspears, looks like you had an open PR for this issue. what was the scoop w/ that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants