简体   繁体   English

什么时候使用淘汰javascript与ASP.NET MVC

[英]when to use knockout javascript with ASP.NET MVC

What factors should I consider before adopting the Knockout JavaScript library for my application? 在为我的应用程序采用Knockout JavaScript库之前,我应该考虑哪些因素?

Currently I have a ASP.NET MVC 2 site. 目前我有一个ASP.NET MVC 2站点。 Most of the navigation and set up of the site is simple get and post actions. 大多数网站的导航和设置都是简单的获取和发布操作。 There are views which have grids / multiple grids where the data is view only. 有些视图具有网格/多个网格,其中数据仅供查看。 All the ajax and javascript is being handled using JQuery. 所有的ajax和javascript都是使用JQuery处理的。 JSON returned from Controllers are few and sparsely used. 从控制器返回的JSON很少并且使用稀疏。 Most of the ajax grids are implemented by sending HTML using partial views. 大多数ajax网格是通过使用部分视图发送HTML来实现的。

There are many factors but one thing which i've found very helpful: 有很多因素,但我发现有一件事非常有帮助:

When you have UI elements which are to be updated AND are sporadically distributed in your webpage eg When you want to add a new job experience, want to show the notification of successful addition on top of the page and increase the count somewhere on the right menu etc. If you use MVC ajax helpers then you would need to specify a single element which needs to be updated with ajax content or write your own huge jQuery.ajax thing. 如果您有要更新的UI元素并且偶尔会在您的网页中分发,例如,当您想要添加新的工作体验时,想要在页面顶部显示成功添加的通知,并在右侧菜单的某处增加计数如果您使用MVC ajax助手,那么您需要指定一个需要使用ajax内容更新的单个元素,或者编写您自己的巨大jQuery.ajax。 Knockout really simplifies this scenario. Knockout确实简化了这种情况。

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

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