我尝试使用jPanel作为可折叠面板,从xml内容动态地显示,但动态创建的面板不出现。见下面如何在jquery中动态创建JPanel?
我容器的图像
<div id="detailTable" style="width:100%;">
</div>
<!--Creating panels (Same thing if i create manually it is created, see the image)-->
<div title="General Properties" class="class">
ad
</div>
<div title="Other Properties" class="class">
ad1
</div>
jQuery的
$('.class').jPanel({
'effect' : 'fade',
'speed' : 'slow',
'easing' : 'swing'
});
//when the user clicks on `Server` (left hand side) the below code is triggered
$('#detailTable').empty();
$('<div>')
.html('<div class="titleBlue">Configuration>'+productname+'>Server</div>'+
'<div title="General Properties" class="class">'+ //Creating panels dynamically
'<table style="border:#2F5882 1px solid;width:100%;" cellspacing="1" cellpadding="1">'+
'<tbody>'+
'<tr>'+
'<th style="width:22%" align="left">Version</th>'+
'<td style="align="left">'+infa9_pm_version+'</td>'+
'</tr>'+
'</tbody>'+
'</table>'+
'</div>'+
'<div title="Other Properties" class="class">'+
'<table style="border:#2F5882 1px solid;width:100%;" cellspacing="1" cellpadding="1">'+
'<tbody>'+
'<tr>'+
'<th style="width:22%" align="left">Home</th>'+
'<td style="align="left">test</td>'+
'</tr>'+
'</tbody>'+
'</table>'+
'</div>')
.appendTo('#detailTable');
更新:
这让我太
$('#detailTable').empty();
$('<div>')
.html('')
.appendTo('#detailTable').delay(10).queue(function(){
$('.class').jPanel({
'effect' : 'fade',
'speed' : 'slow',
'easing' : 'swing'
});
});
嗨,谢谢你的回答,但面板只有在我点击div时才会出现,如何才能在创建后立即显示? – abi1964
您可以通过编程方式触发点击。更新了答案。 – Jayendra
谢谢,'.delay(10).queue'也帮助我..查看我更新的问题 – abi1964