문제

I have several views in my project and each applies bindings on its own tag like this:

(note: periods represents more code removed to show the problem I have, I created a fiddle a bit more complete here: http://jsfiddle.net/EYB8E/)

HTML

<div id="ui-main"> 
    ... html code bound to mainViewModel here
<div/>

...

<div id="ui-partial"> 
    ...
</div>

javascript

function MainViewModel() {...};

var mainViewModel = new MainViewModel();
ko.applyBindings(mainViewModel, document.getElementById("ui-main"));

...
function PartialViewModel() {...};
ko.applyBindings(partialViewModel, document.getElementById("ui-partial"));

but the second applyBindings does not apply because: "Error: You cannot apply bindings multiple times to the same element.". (see it in jsFidle: http://jsfiddle.net/EYB8E)

I cannot figure out what is wrong.

도움이 되었습니까?

해결책

Your <div /> should be </div>.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top