Your <div />
should be </div>
.
knockoutjs cannot apply bindings to different ids
-
07-07-2023 - |
문제
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.
해결책
제휴하지 않습니다 StackOverflow