Pra*_*lur 2 javascript jquery-mobile
我有4个可折叠设备:1个可折叠的一年中的每个季度.根据当前月份,相应的可折叠应该在文件准备就绪时扩展.然而,这不起作用.
<script type="text/javascript">
$(document).ready
(
function()
{
var today=new Date();
var month=today.getMonth()+1;
alert(month);
if(month>9)
{
$('#qFourCollapsible').trigger("expand");
}
else if(month>6)
{
$('#qThreeCollapsible').trigger("expand");
}
else if(month>3)
{
$('#qTwoCollapsible').trigger("expand");
}
else
{
alert("in else");
$('#qOneCollapsible').bind("expand", function () {
alert('Expanded');
});
}
}
);
</script>
<html>
<div data-role="collapsible-set" data-theme="b" data-content-theme="c" data-collapsed="false" id="qOneCollapsible">
<div data-role="collapsible">
<h2>January-March</h2>
<table id="quarterOneTable">
</table>
</div>
</div>
<div data-role="collapsible-set" data-theme="b" data-content-theme="d" id="qTwoCollapsible">
<div data-role="collapsible">
<h2>April-June</h2>
<table id="quarterTwoTable">
</table>
</div>
</div>
<div data-role="collapsible-set" data-theme="b" data-content-theme="c" id="qThreeCollapsible">
<div data-role="collapsible">
<h2>July-September</h2>
<table id="quarterThreeTable">
</table>
</div>
</div>
<div data-role="collapsible-set" data-theme="b" data-content-theme="d" id="qFourCollapsible">
<div data-role="collapsible">
<h2>October-December</h2>
<table id="quarterFourTable">
</table>
</div>
</div>
</html>
Run Code Online (Sandbox Code Playgroud)
所以,正如你所看到的,我试图以两种方式扩展可折叠.1: $('#qFourCollapsible').trigger("expand"); 2: $('#qOneCollapsible').bind("expand", function () {
alert('Expanded');他们俩都没有工作.第二种方法正常工作,只有点击折叠后才会显示警报展开.但是,我希望它可以根据当前月份自行扩展.
当前的api文档提供了新的信息
$("#resCollapsable").collapsible("expand");
Run Code Online (Sandbox Code Playgroud)
这适用于此线程中的先前代码似乎不再起作用.
| 归档时间: |
|
| 查看次数: |
5763 次 |
| 最近记录: |