Jquery Mobile可折叠文件在清空()后失败?
我动态生成了一个可折叠文件,但在调用Jquery Mobile可折叠文件在清空()后失败?,jquery,jquery-mobile,jquery-mobile-collapsible,Jquery,Jquery Mobile,Jquery Mobile Collapsible,我动态生成了一个可折叠文件,但在调用.empty()并动态生成另一个可折叠文件后,它将不会显示为可折叠文件。我想要的只是在.empty()事件之后正确生成可折叠文件 第一次动态折叠: 在.empty()之后,使第n次动态折叠: 下面是我如何创建可折叠并附加按钮的一些示例: function createButton(buttonText,hrefLink,onclk,id) { console.log('=>'+onclk); var button = '<a h
.empty()
并动态生成另一个可折叠文件后,它将不会显示为可折叠文件。我想要的只是在.empty()
事件之后正确生成可折叠文件
第一次动态折叠:
在.empty()
之后,使第n次动态折叠:
下面是我如何创建可折叠并附加按钮的一些示例:
function createButton(buttonText,hrefLink,onclk,id) {
console.log('=>'+onclk);
var button = '<a href="'+hrefLink+'" onClick="'+onclk+'" class="ui-btn ui-btn-corner-all ui-shadow ui-btn-up-c" data-role="button" data-theme="c"' + '' + 'id="' + id + '"' + '>' +
'<span class="ui-btn-inner ui-btn-corner-all">' +
'<span class="ui-btn-text">' + buttonText + '</span>' +
'</span>' +
'</a>';
return button;
}
function createCollapsible(collapsibleText,id){
var collapsible = "<div data-role='collapsible' data-theme='a' id='set" + id + "'><h3>" + collapsibleText + "</h3></div>";
return collapsible;
}
function createCurrentSets(station,set,container){
$('#sampleSets').empty();
$('#addSampleSet').hide();
if(set === 'SNGL'){
save_data('singleMultiContainer','single');
save_data('set',set);
$('#sampleSets').append(createCollapsible('Single',set));
for(i=0;i<ls.length;i++){
if(ls.key(i).match(stationSetContainerRegex)){
var query = ls.key(i);
var data = query.split('&');
if(data[0]===station && data[1] === set){
$('#set'+set).append(createButton(data[2],'#sampleParametersPage',"getJsonFromLocalStorage('"+station+'&'+set+'&'+data[2]+"');",data[2])).trigger('create');//createButton(set,'#setProperties',"changeSet(this.id)",set));
console.log('Current Sample created');
}
}
}
}else if ( set!== 'SNGL'){
$('#sampleSets').append(createCollapsible('Set ' + set, set));
for(i=0;i<ls.length;i++){
if(ls.key(i).match(stationSetContainerRegex)){
var query = ls.key(i);
var data = query.split('&');
if(data[0]===station && data[1] === set){
$('#set'+set).append(createButton(data[2],'#sampleParametersPage',"getJsonFromLocalStorage('"+station+'&'+set+'&'+data[2]+"')",data[2])).trigger('create');//createButton(set,'#setProperties',"changeSet(this.id)",set));
}
}
}
}
}
函数createButton(按钮文本、hrefLink、onclk、id){
console.log('=>'+onclk);
var按钮=“”;
返回按钮;
}
函数createCollapsable(可折叠文本,id){
var collapsable=“”+collapsabletext+”;
返回可折叠;
}
函数createCurrentSets(站点、集合、容器){
$(“#样本集”).empty();
$('#addSampleSet').hide();
如果(设置=='SNGL'){
保存_数据('singleMultiContainer','single');
保存_数据('set',set);
$('#sampleSets').append(createcollapsable('Single',set));
对于(i=0;i在将项目动态附加到当前页面或已存在的页面时,需要手动增强项目以应用JQM样式
对于可折叠小部件,请在附加项目后调用下面的
$(".selector").collapsible();
参考:#示例集是可折叠的id?如果是,则应清空并附加到其子div。ui可折叠内容
@Omar#示例集是我附加在createcollapsable(可折叠文本,id)中创建的可折叠文件的div
function。请共享您的html标记。@Omar好了,我编辑了问题内容并添加了HTMLTanks。您需要调用可折叠增强,请使用$(“#可折叠"id”)。可折叠()
添加新的后。您能指出它在jquery mobile中的位置吗documentation@Ch32k0不幸的是,jQuery Mobile的文档中没有提到这一点。这一结果是通过多次试验获得的,这是掌握JQM的方法:)哈哈哈,谢谢!我才刚开始;)@Ch32k0你一定会喜欢的;)祝你好运!编辑:你可以查看jquerymobileapi中的所有小部件。
$(".selector").collapsible();