Domanda

I have a Durandal view on which I load 2 other views through composition, like so:

<div data-bind="customVisible: showingList, compose: {model: 'app/element/elementList', activationData: $root}"></div>
<div data-bind="customVisible: showingDetail, compose: detail"></div>

"showingList" and "showingDetail" are boolean observables. "detail" is another observable, which initially is created like:

this.detail = ko.observable(null);

and later (on a button click) filled like:

this.detail({model: 'app/element/elementDetail', activationData: item);
        if(!condition){

            this.showingList(false);
            this.showingDetail(true);
        }

The problem is that whenever the "showingDetail" changes, the "compose" binding fires again (If I comment out the "showingDetail" line, problem disappear)

Is there a reason for the "compose" binding to fire twice when some other binding has to update??? Is it maybe otherwise (that "compose" is causing my "customVisble" to fire again)???

The "customVisible" binding only updates the "style.display" property of the "div" element

The underlying problem is that the "activate" and "compositionComplete" events are firing twice for the child views

Thanks in advance

È stato utile?

Soluzione

What version of knockout are you using? In 3.0 they have made a change where bindings are evaluated separately. See this post for a really nice intro to the changes:

http://www.knockmeout.net/2013/10/knockout-3-highlights.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top