我嘗試使用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