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

BindingList changes #22

Open
pbouzakis opened this issue Jul 27, 2012 · 5 comments
Open

BindingList changes #22

pbouzakis opened this issue Jul 27, 2012 · 5 comments

Comments

@pbouzakis
Copy link
Collaborator

We need a helper to easily map binding list changes to ko observable arrays.

Currently this is what we have going on in Beretta:

terms.addEventListener("iteminserted", function (ev) {
    var term = ev.detail.value;
    that.terms.push(term);
});

// TODO Listen for "itemremoved", "itemmutated", "itemchanged"

So two issues, need a helper, and need to listen to all events.

@domenic
Copy link
Contributor

domenic commented Jul 27, 2012

I think the best approach would be to create a custom Knockout binding that binds to binding lists the same way Knockout currently does to observable arrays.

@pbouzakis
Copy link
Collaborator Author

Good idea, will implement something once Roman gets his version of observable arrays into the harness.

@domenic
Copy link
Contributor

domenic commented Aug 3, 2012

Meh it looks like we'll need a way to keep two binding lists in sync though, just for viewmodel lists vs. harness lists. Maybe WinRT or WinJS has something already---it's such an obvious thing to do. I'll ask StackOverflow.

@domenic
Copy link
Contributor

domenic commented Aug 3, 2012

ORRRR we could let the custom binding take a view model mapper O_o.

div(data-win-control="ListView" data-bind="list: theList, listConverter: theConverter")
function TermsListViewModel(termsBindingList) {
    this.list = termsBindingList;
    this.listConverter = function (term) {
        return new TermsViewModel(term);
    };
}

I guess maybe this just moves the synchronization code into the custom binding though, which isn't a huge win necessarily. Hmm.

@domenic
Copy link
Contributor

domenic commented Aug 3, 2012

ORRR we could do the view model mapping as part of the itemTemplate stuff, like I think we are doing currently with templateRendererFactory and componentRendererFactory.

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