2
我在其他页面发现了这个问题和解决方案,但我仍然无法获得完美的一个。我正在循环200个对象的数组。Jquery mobile(ListView)触发器试图插入大量行时创建缓慢
var stringBuffer = [];
for(var i = 0; i < array; i++) {
stringBuffer.push('<input type="radio" class="select_options" data-iconpos="right" onClick ="callClosePopup(event);" name="items" id="radio_' + array[i].ConditionId + '" ' + checked + 'value="' + array[i].ConditionId+'_' + array[i].Description + '"/><label data-corners="false" data-iconshadow="false" style="border-bottom:1px solid rgb(0,0,0)" for="radio_' + array[i].ConditionId + '">' + array[i].Description + '</label>');
}
var combinedHtml = stringBuffer.join("")
$("#myListView").html(combinedHtml).trigger("create"); <=== This line consumes a lot of time (around 9 seconds on my Moto G).
任何想法,以改善这一点? PS:我正在使用jQuerymobile v-1.3.1。
对我来说,最终的解决方案,这加速了我的应用程序有很多,是为了消除使用这么多元素。它在$ .create()上,jQuery花了很多时间来生成它的修改和处理程序。 –
shmolf