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

Binding on .length of an object #142

Closed
justinbmeyer opened this issue Nov 6, 2012 · 2 comments
Closed

Binding on .length of an object #142

justinbmeyer opened this issue Nov 6, 2012 · 2 comments

Comments

@justinbmeyer
Copy link
Contributor

If I have a compute like:

var obs = new can.Observe();
var compute = can.compute(function(){
  var txt = "';
  obs.each(function(val){
    txt+= val
  });
  return txt;
})

It should produce change events when I add or remove properties to obs.

@dispatchrabbi
Copy link
Contributor

Here's what I think is happening here: compute keeps an eye out for when .attr() is called on an observable in its value function, but it's not recognizing when .each() is called (probably because .each() calls .attr() on different things each time). More later, hopefully after fixing.

@justinbmeyer
Copy link
Contributor Author

This works now by using can.Observe.keys( observe ) -> [key1, key2].

When you call the keys function, it indicates that you are reading from a special __keys property. When you add or remove properties to the observe, a __keys event is triggered.

__keys is now a reserved property on can.Observes.

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

3 participants