开发者

Knockout JS + Partial Views and Validation? [duplicate]

This question already has answers here: Knockout + mvc 3 + Validation (4 answers) Closed 9 years ago.

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜