jQuery的模板VS在ASP.NET MVC局部视图 [英] jQuery Templates vs Partial Views in ASP.NET MVC

查看:155
本文介绍了jQuery的模板VS在ASP.NET MVC局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在看jQuery的模板。它看起来非常有趣 - 易语法,易于使用,非常干净。

I'm taking a look at jQuery templates. It looks really interesting - easy syntax, easy to use, very clean.

不过,我真的不能明白为什么它的更好的使用jQuery的模板,而不是仅仅通过AJAX获取部分景色。它只是好像部分景色会更容易维护,并有助于避免code的重复。

However, I can't really see why it's better to use jQuery templates instead of simply fetching partial views via AJAX. It simply seems like the partial views would be much easier to maintain and helps to avoid duplication of code.

我想使用jQuery模板。但是,当会比部分景色好?

I want to use jQuery templates. But when would it be better than partial views?

推荐答案

我同意这些确实重叠。有实现相同的软件几种不同的方法,等等你在使用什么样的决定,取决于你的个人preference和软件的情况下。

I agree that these do overlap. There are several different ways to implement the same piece of software, and much of your decision on what to use depends on your personal preference and the context of your software.

局部视图的优点:


  • 类型安全(如果使用强类型的ViewModels)

  • 允许静态语法和类型检查。

  • 全code完成/语法高亮在Visual Studio的支持

jQuery的模板优点:


  • 允许网页以执行回发之前或没有任何回发到服务器一侧的所有更新。使用HTML5驱动的离线功能创造大量ajaxed接口时,也可能这是很方便的。

  • 您可以从JSON格式的服务器检索数据并呈现为HTML。 JSON是更短的HTML格式,所以这可以用一个缓慢的互联网连接时使数据项的长列表页面加载时间的差异。

因此​​,在本质部分观点的更稳定和jQuery模板(阿贾克斯的网站)的更好的性能选择。因此,我用流量较少的网页,这就需要能够迅速开发和jQuery模板严重ajaxed网页的局部视图,其中性能真的很重要。

So in essence partial views are the more stable and jquery templates are (for ajax websites) the more performant choice. I therefore use partial views for less frequented web pages which need to be developed quickly and jQuery templates for heavily ajaxed web pages where performance really matters.

这篇关于jQuery的模板VS在ASP.NET MVC局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆