我正在从动态提取的数据中克隆一个
<li>
模板和一个后续<div>
模板(链接到该模板)。<li>
创建列表后,我可以使用以下命令刷新 s-scrollwrapper: $ ('#rlist').data('iscroll').refresh(); 这很棒。但是,当涉及到模板时,我无法让它们中的每一个都刷新。我试过上面的方法 jQT.setPageHeight(); 来自链接的 onClick 方法<li>
和每个方法<div>
被创建的时间。我什至尝试将一个新的 s-scrollwrapper 附加到已经形成<divs>
的中,但似乎都不起作用。
function loadInfo(){
...
fillRedSection(availableArray, $('#entryTemplate'));
$('#rlist').data('iscroll').refresh();
//Tried ways to refresh scroll of the cloned divs...nothing seems to
work
}
function fillRedSection(arr, template){
//iterating through the JSON data
for (i = 0; i<arr.length; i++){
var dataLocation = arr; //Data arr
var row = dataLocation[i].id; //id# coming with JSON data
var newEntryRow = template.clone(); //cloned <li> template
from HTML
newEntryRow.removeAttr('id');
newEntryRow.removeAttr('style'); //removing hidden style
newEntryRow.attr('id', 'red-label'+row); //renaming the <li>
id with the id from JSON
newEntryRow.attr('class', 'arrow'); //JQT class
newEntryRow.appendTo('#redlist ul'); //placing cloned <li>
into ul
newEntryRow.find('a').attr('href','#red-'+row);//renaming href
so it will link to the cloned <div>
var newEntryDetails = $('#red-description').clone(true,
true);//cloning the div template
newEntryDetails.removeAttr('id');
newEntryDetails.removeAttr('style');//removing hidden
style
newEntryDetails.attr('id', 'reds-'+row);//renaming id so
the <li> href can link to it
//1 Possible attempt at adding the scroll class as each
div is created
// Hopefully avoiding problem of cloned scrolls with the
same id name
/*var newScroll = $('.tester');
newScroll.removeAttr('id');
newScroll.attr('id', 'scroll-'+row);
newScroll.attr('class', 's-scrollwrapper');*/
newEntryDetails.appendTo('#jqt'); //append cloned <div> to
the main <#jqt> div.
newEntryDetails.find('h4').text(dataLocation[i].business_name);//
filling div from JSON
...
}
}
//Attempt to refresh iScroll on the div that is being clicked on from
the <li>
//used onClick="refreshScroll()
refreshScroll {
jQT.setPageHeight();
}
似乎没有任何效果。我将不胜感激有关此问题的任何帮助。