0

我有一个视图 xyz.cshtml

我在其中渲染了两个局部视图ab. 现在在 xyz.cshtml页面中我有一个按钮来切换视图。但是当我更改视图时出现问题,它不会对新加载的视图应用绑定。

提前致谢 。

4

1 回答 1

1

If you load the partial views dynamically (I mean if they aren't both loaded on page load, but instead requested on button click) then Knockout will have 0 knowledge of those bindings.

Off the top of my head I would basically have two view models and when you click the button and a new partial view is loaded in run ko.applyBindings on the loaded in markup.

于 2013-11-12T19:58:02.310 回答