简体   繁体   English

有没有什么方法可以限制淘汰表.js应用程序的范围?

[英]Is there any way to limit the scope of a knockout.js application?

I have a legacy project which I have been approved to work in a knockout.js module. 我有一个旧项目,该项目已被批准可以在knockout.js模块中使用。 This is great however the application is extremely complex and I need to use some of the pre-built form validation of our application. 这很棒,但是应用程序极其复杂,我需要使用我们的应用程序的一些预先构建的表单验证。 My form validators work fine until a dynamic template gets switched out. 我的表单验证器可以正常工作,直到切换出动态模板为止。 I can't for the life of me figure out the error. 我无法终生发现错误。 Nothing in the console and my vast debugging efforts have been fruitless. 控制台中没有任何内容,我的大量调试工作也没有结果。 I'm thinking that my solution could be something along the lines of limiting the scope of the knockout application similar to how one can declare ng-app in angular.js . 我认为我的解决方案可能类似于限制敲除应用程序的范围,类似于如何在angular.js声明ng-app I can't find a working example of how to do this or any documentation relevant to knockout.js 我找不到如何执行此操作的有效示例,也找不到任何与knockout.js相关的文档

Any help or suggestion is appreciated. 任何帮助或建议,表示赞赏。 Thank you ladies and gentlemen. 谢谢女士们先生们。

ko.applyBindings takes an optional second parameter which is an element to treat as the root. ko.applyBindings采用可选的第二个参数,该参数是被视为根的元素。

eg 例如

ko.applyBindings(viewModel, $("#app")[0])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM