Have bindings changed?

I'm running into a problem with bindings that are no longer updating. I've got a controller with a collection component and a view.
The view will programmatically instantiate a child component at a later point in time. The child component will be chosen based on the window size, there are multiple child components for multiple form-factors.

My page view uses a binding to connect the collection to the content once the content has been created:

enyo.kind({
    kind: "PageController",
    components: [{
        name: "programsCollection",
        kind: "enyo.Collection"
    }, {
        name: "myPageView",
        kind: "PageView"
    }]
});

enyo.kind({
    name: "PageView",
    bindings: [{
        from: "controller.$.programsCollection", // collection is found
        to: "$.content.programsCollection", // $.content does not exist yet when binding is initialized
        allowUndefined: false
    }],
    createContent: function() {
        this.createComponent({
            name: "content",
            kind: "PageContent"
        });
        // $.content does exist now
    }
});

enyo.kind({
    name: "PageContent",
    components: [{
        name: "myRepeater",
        kind: "enyo.DataRepeater"
    }],
    bindings: [{
        from: "collection", // undefined
        to: "$.repeater.collection"
    }]
});
At instantiation time, the $.content component does not exist yet. It is created later on using PageView.createComponent(). In enyo 2.4 the binding got updated as soon as the $.content component was created, but in enyo 2.5 it is not updated.

I'm currently working around it by having the pageView bind the collection from it's controller to itself, and having the pageContent bind the collection from it's owner (which is the pageView). It seems kind of backwards to bind to the owner though..

What's the correct way to do this in enyo 2.5?

Comments

  • edited March 2015
    It may be a typo in your sample code, but you are binding to content's programsCollection, but in
    PageContent (content), your binding from collection
  • Woops, yes that's indeed a typo, seems I was a bit sloppy in writing my example code. In my project code all the paths were correct. That is, using enyo 2.4 they worked just fine, its only in 2.5 that they stopped working.

    The changelog does mention changes to the bindings, but I'm not sure if I was just doing things wrong previously or if the new behaviour is a bug, or if there's a different more correct way to handle this.
Sign In or Register to comment.