隐藏的输入太多会影响页面渲染速度吗? [英] Does too many hidden inputs affect the page rendering speed?

查看:131
本文介绍了隐藏的输入太多会影响页面渲染速度吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在需要在隐藏字段中保留一些关于我的控制的数据。我正在使用MVC 3进行记录。我担心的是我会像穷人的视角一样使用隐藏的领域。在这样做的过程中,我觉得我会冒着导致页面慢慢(或慢)放缓的风险。下面是我正在谈论的一个例子。

所以简而言之,页面上会隐藏很多字段会导致页面缓慢运行/呈现?



 < div> 
< div> 1.< / div>
< div>
输入桥腿的测量值(从左到右,顶部,然后是底部的记录):
(我是这种形式的许多行之一)< / div>
< div>< input type =textid =1name =leg/>< input type =hiddenid =1name =dataidvalue = 101/>
< input type =textid =2name =leg/>< input type =hiddenid =2name =dataidvalue =102/> ;
< input type =textid =3name =leg/>< input type =hiddenid =3name =dataidvalue =103/> ;
< input type =textid =4name =leg/>< input type =hiddenid =4name =dataidvalue =104/> ;
< input type =textid =5name =leg/>< input type =hiddenid =5name =dataidvalue =105/> ;
< input type =textid =6name =leg/>< input type =hiddenid =6name =dataidvalue =106/> ;
< input type =textid =7name =leg/>< input type =hiddenid =7name =dataidvalue =107/> ;
< input type =textid =8name =leg/>< input type =hiddenid =8name =dataidvalue =108/> ;
< input type =textid =9name =leg/>< input type =hiddenid =9name =dataidvalue =109/> ;
< input type =textid =10name =leg/>< input type =hiddenid =10name =dataidvalue =110/> ;< / DIV>
< div>< input type =submitvalue =Submit/>< / div>
< / div>

我最终将拥有80行的页面,并且每行都有多个控件。鉴于这种情况,我是否过度使用或者是否有合理的担忧?

解决方案

您可以使用自定义属性为您的可见输入避免使用这些额外的隐藏字段。

 < input type =textid =1name =legdata-id =101/> 

使用jquery,您将获得 data-id > $>

作为一个便笺,既然你说你有多行,请确保你没有重复您的输入ID。


I'm at the point where I'll need to keep some data about my control in hidden fields. I'm using MVC 3 for the record. My worry is that I'll be using the hidden fields like a poor man's viewstate. In doing that, I feel that I'll be running the risk of causing the page to renderly slowly (or slower). An example of what I'm talking about is below.

So in short, will having a lot of hidden fields on a page cause the page to run/render slowly?

An example of what one row will look like:

<div>
    <div>1.</div>
    <div>
        Enter the measurements for the bridge legs (record from left to right, top, then bottom):
        (I am one of many rows in this form.)</div>
    <div><input type="text" id="1" name="leg" /><input type="hidden" id="1" name="dataid" value="101" />
        <input type="text" id="2" name="leg" /><input type="hidden" id="2" name="dataid" value="102" />
        <input type="text" id="3" name="leg" /><input type="hidden" id="3" name="dataid" value="103" />
        <input type="text" id="4" name="leg" /><input type="hidden" id="4" name="dataid" value="104" />
        <input type="text" id="5" name="leg" /><input type="hidden" id="5" name="dataid" value="105" />
        <input type="text" id="6" name="leg" /><input type="hidden" id="6" name="dataid" value="106" />
        <input type="text" id="7" name="leg" /><input type="hidden" id="7" name="dataid" value="107" />
        <input type="text" id="8" name="leg" /><input type="hidden" id="8" name="dataid" value="108" />
        <input type="text" id="9" name="leg" /><input type="hidden" id="9" name="dataid" value="109" />
        <input type="text" id="10" name="leg" /><input type="hidden" id="10" name="dataid" value="110" /></div>
    <div><input type="submit" value="Submit" /></div>
</div>

I will end up having a page that has 80 rows and each row having multiple controls. Given this situation am I overworrying or do I have a legitimate concern?

解决方案

You can avoid those extra hidden fields using custom attributes for your visible inputs

<input type="text" id="1" name="leg" data-id="101" />

Using jquery, you would get the data-id attribute like this

var id = $('#1').data('id');

As a side note and since you said that you have multiple rows, be sure you're not repeating your input ids.

这篇关于隐藏的输入太多会影响页面渲染速度吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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