I've just upgraded to 2.3.0 and now I'm getting the error
You cannot apply bindings multiple times to the same element.
that I wasn't getting in 2.2.1.
I'm getting a partial view from my MVC controller and adding it to the page after clicking on an href. The error happens the second time I click on the link to get the partial view. I'm doing this multiple times.
Is there a way to clear this out and avoid the new error thrown?
Here's my code:
$.get(url + "GetAssignedCompaniesView?layoutId=" + layoutId + "&noCache=" + new Date().getMilliseconds(), function (result) {
$("#editAssignedPartial").html($(result));
showEditAssignedArea(true);
$(window.document).ready(function () {
// error is thrown here
ko.applyBindings(self, window.document.getElementById("editAssigned"));
$("#layoutId").attr("value", layoutId);
updateTypeHiddenElement.attr("value", "companies");
});
});
<div id="editAssignedPartial">
</div>
$(document).ready(function () {
'use strict';
var vm = new Vm();
ko.applyBindings(vm, document.getElementById("area1"));
});
You just have to remove the bindings before you use 'applyBindings' again.
ko.cleanNode($element[0]);
should do the trick. HTH.