淘汰赛 JS +部分视图和验证?
我对用于创建网站的淘汰赛和纯 js/html 框架很陌生。不过我确实有 ASP MVC 的经验。
在我当前的项目中,我最初使用 MVC 来完成后端工作和前端 ui 工作。插入大量 jquery 和其他事件框架等。
无论如何,我正在考虑使用 PhoneGap 将项目移动到移动设备,因此我将后端问题从 ASP MVC 应用程序转移到 Web 服务(仍然是 ASP MVC,但是只是公开和使用数据,没有视图)。所以这让我想到,后端将负责接收数据并自动绑定它,验证模型,然后持久化它,并返回相关结果。这样PhoneGap版本可以复用当前前端使用的jquery和javascript,并且可以直接通过PhoneGap消费数据并将数据发送到服务。
话虽如此,我当前的 Web 应用程序将变得有点多余,因为我使用 asp mvc 框架没有任何好处,因为相同的工作是在 Web 服务上执行的,而且大部分繁重的工作都是在客户端,尽管我确实大量使用客户端验证和部分可重用视图。
综上所述,我正在考虑废弃我的网络应用程序,并将其转移到使用 Knockout 并直接与服务通信,以消除中间人。但是,我仍然需要能够重用部分视图,并且需要对模型进行某种验证。
Knockout 可以为我提供此功能吗?或者还有其他插件/框架可以让我做到这一点吗?
I am new to knockout and pure js/html frameworks as a whole for creating web sites. However I do have experience with ASP MVC.
In my current project I was originally using MVC to do the back end work, and the front end ui stuffs. With alot of jquery plugged in and other event frameworks etc.
Anyway I am looking at moving the project to mobile devices using PhoneGap, and due to this am moving the backend concerns from the ASP MVC app to a web service (still ASP MVC, but just exposes and consumes data, no views). So this got me thinking, the back end will be responsible for receiving data and auto binding it, validating the model, then persisting it, and returning a relevant result. This way the PhoneGap versions can re-use the jquery and javascript currently used on the front end, and they can consume the data and send the data to the service directly through PhoneGap.
Now with that said, my current web app would become a little redundant, as there is no benefit in my using the asp mvc framework as the same work is carried out on the web service, and also most of the heavy work is client side, although I do heavily make use of clientside validation and partial re-useable views.
So with this all being said, I am looking at scrapping my web app, and just moving it to use Knockout and communicate directly with the service, to cut out the middle man. However I would still need to be able to re-use partial views and would need some sort of validation for the models.
Can Knockout provide this functionality for me? or are there any other plugins/frameworks that allow me to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Knockout 具有内置模板功能(使用 jquery.tmpl.js 或者如果您选择也可以使用其他模板插件)。 Knockout 还可以与其他 js 框架很好地配合,因此使用 jquery 没有问题,并且大多数 jquery 插件都应该可以从 Knockout 中访问。 Knockout 文档中还有一些使用 jquery 验证插件的示例。
验证示例
数据绑定语法
模板
Knockout has built in templating features (using jquery.tmpl.js or it can use other templating plugins if you choose). Knockout also plays nicely with other js frameworks so using jquery is no problem and most jquery plugins should be accessible from within Knockout. There are also a few examples in the Knockout documentation that use the jquery validation plugin.
Validation Example
Data-Binding Syntax
Templates