I have a View xyz.cshtml

in which i render two partial views a and b . Now in xyz.cshtml page i have a button to switch view . But problems comes when i change view it doesn't apply binding on newly loaded view .

Thanks in advance .

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top