Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Mootools Multiselect check all在Internet explorer中速度非常慢_Javascript_Jquery_Html_Internet Explorer 8_Mootools - Fatal编程技术网

Javascript Mootools Multiselect check all在Internet explorer中速度非常慢

Javascript Mootools Multiselect check all在Internet explorer中速度非常慢,javascript,jquery,html,internet-explorer-8,mootools,Javascript,Jquery,Html,Internet Explorer 8,Mootools,当下拉列表中有许多值(大约100个值)时,单击分组多选下拉组件中的“全部”链接时,我们将面临性能问题 这个问题只在IE8中出现,在其他浏览器中也可以正常工作。经过初步分析,我们发现 multiselect.js文件的函数changeItemState中的以下几行导致了IE8中的此问题。你能为我们提供一些解决方法吗 monitor.set('html', ' + this.changeMonitorValue(item.getParent()) + ); monitor.title = thi

当下拉列表中有许多值(大约100个值)时,单击分组多选下拉组件中的“全部”链接时,我们将面临性能问题

这个问题只在IE8中出现,在其他浏览器中也可以正常工作。经过初步分析,我们发现

multiselect.js文件的函数changeItemState中的以下几行导致了IE8中的此问题。你能为我们提供一些解决方法吗

monitor.set('html', '
 + this.changeMonitorValue(item.getParent()) + 
);
monitor.title = this.getHoverTitle(item.getParent());

不确定您何时删除了实际代码,但当您说您有100个值时——特别是使用getter时——这可能是IE8或更少版本中的一个问题

javascript中的字符串是不可变的。这意味着,如果需要连接100个字符串,它将创建一个新字符串,向其中添加下一个字符串,并清理100次。这在IE中的性能不是很好,因此很多人习惯于使用
Array.join(“”)

var foo = 'a' + 'b' + 'c' + 'd', // faster in modern and mobile browsers
    bar = ['a','b','c','d'].join(''); // faster by ~50% IE7, IE8

然而,在移动设备、android和现代浏览器中,数组连接技巧的速度较慢

另一种优化方法是添加更改处理程序,在表单操作(您的模型)期间将当前值导出到数组中,这样就不需要在提交事件中一次性获得100个值

由于节点的父节点是不可变的(很可能),因此无需一直转到
item.getParent()
,您可以在开始之前一次性执行,甚至可以直接引用
item.parentNode
,以避免函数调用

发布
changeMonitorValue
源代码,以获得可能处于次优状态的优化。我想你在用什么

如果是这样,可以进行很多优化。然而,这是插件作者的事情


有创意:)

你能制作一个JSFIDLE os JSBin来重现你的问题吗?顺便问一下,为什么引号和concat
+
会登录
这个.changeMonitorValue