开发者

ASP.NET MVC 2: Is the Model kept up to date in the View?

I'm cu开发者_开发知识库rrently using jQuery to keep things up to date in the View as options are selected in my Form. But my Model reflects those form elements so I was starting to think: is it possible to keep the model elements up to date as they are changing?


Knockout JS is your friend:

http://knockoutjs.com/

Edit: It helps you move your model to the client side so that your JS code can keep it up-to-date according to user interaction. From there on, you can simply move it back, ready-to-use, to the server side. It's one more thing to learn but in complex views, it removes complexity and avoids the separation of model management between client and server: Everything's now in the client.

So, all in all, you'll probably have a little more code but it will be far more easy to read and maintain.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜