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

Enhancement - kb.observableArray - as in ko.observableArray for Models with an Array (not a collection) #118

Closed
joantune opened this issue Jun 16, 2014 · 2 comments

Comments

@joantune
Copy link

Hi!

I don't know if many people are on board with this as I am, but if you have a simple model that has an Array as an attribute, if you do
var something = kb.observable(model, "arrayProperty") you don't get the value of the array in something, only the full model.

How about having a kb.observableArray(model, "arrayProperty") any subsequent changes to the observable Array would trigger a set on the model, and the other way around.

@joantune
Copy link
Author

My bad - I had a typo and was using ko.observable instead of kb.observable, actually a kb.observable is created (although it is not a ko.observableArray), anyway, I made that array into a collection following the advice here as I might need to change that (i.e. not only a read only array). Anywhoo, I don't know if transforming that into an observableArray will be so useful given the workarounds:

  • creating a kb.observable;
  • manning up and making it a Backbone.Collection

Anyway, if someone thinks is useful +1 it here

@kmalakoff
Copy link
Owner

We have been using BackboneORM, but in the past we used BackboneRelational to handle nested arrays. They will create kb.collectionObservables (which are ko.observableArrays). Or you can just use a collection as you did.

I'll close for now...

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

2 participants