daniel
daniel

Reputation: 35693

Breeze.js and knockout.js applybindings a second time

The first time i click the Button everything is bound correct. But when i click the button a second time all the old values are still bound to my view? How can i reapply new bindings to my breeze.js viewmodel?

JS

var manager = new breeze.EntityManager('/breeze/corporations');

$("#myButton").click(function () {

    var query = breeze.EntityQuery.from("Corporations").where("Name", "startsWith", "Zen");

    manager.executeQuery(query)
                   .then(querySucceeded)
                   .fail(queryFailed);

    function querySucceeded(data) {
        var ib = $("#infoBox")[0];
        ko.applyBindings(data, ib);
    }
});

Html

<div id="infoBox""> 
    <ul data-bind="foreach: results">
        <li>
            <strong><span data-bind="text:City"></span></strong>
            <span data-bind="text:Name"></span>     
        </li>
    </ul>
</div>

Upvotes: 0

Views: 134

Answers (1)

Tomas Kirda
Tomas Kirda

Reputation: 8413

You should not reapply bindings. You should update only data. You should not apply bindings multiple times to the same DOM elements.

Upvotes: 1

Related Questions