2012-12-12 68 views
0

我想做某事相似喜欢这里jQuery Mobile的可折叠的事件:JQuery-Mobile collapsible expand/collapse event没有发射

我无法得到它的工作!即使我复制代码并将其放入我的网站中,也不会发生任何事情,只需点击可折叠的代码即可。

<div data-role="page" id="test"> 
    <div data-role="collapsible" id="my-collaspible"> 
     <h3>My Title</h3> 
     <p>My Body</p> 
    </div> 
</div> 

这里是js代码:

$('#my-collaspible').bind('expand', function() { 
    alert('Expanded'); 
}).bind('collapse', function() { 
    alert('Collapsed'); 
}); 

有什么建议?我不知道问题出在哪里!

回答

1

这是恩:HTTP:// jsfiddle.net/quangtuyn/s4k7d/

您可以检查agian

希望它对你有用

+0

我不知道,你必须使用$(文件)。就绪(函数 谢谢! – RaveN

0

这是一个错字吗? “my-collaspible”? 尝试改变的标记和jQuery选择的ID为正确的拼写

0

也许你需要使用坍塌事件

$("#my-collaspible").trigger("collapse"); 

,扩大事件

$("#my-collaspible").trigger("expand"); 
0

你需要找到Jquery UI绑定到的元素。

$("[data-role*='collapsible-set']").bind('expand', FixJQueryMobileUIFails) 

function FixJQueryMobileUIFails(element) { 
    StraightenColumnsforQueryUIHeaders(element); 
    StraightenCornerNextToHeaderInLastTreeElement(element); 
    RoundBottomCornerInLastTreeElement(element); 
}