I am using Jquery Mobile's Collapsable framework .
我正在使用Jquery Mobile的可折叠框架。
How can i close (collapse) all the other collapsable div's except the current clicked one ??
如何关闭(折叠)所有其他可折叠div除了当前点击的一个?
This is my code
这是我的代码
$('.my-collaspible').on('collapsibleexpand', function() {
$(this).off('collapsibleexpand');
});
This is my fiddle
这是我的小提琴
http://jsfiddle.net/cod7ceho/9/
Thanks in advance .
提前致谢 。
2 个解决方案
#1
1
You need to use .collapsible("collapse")
for collapsing other .my-collaspible
items:
您需要使用.collapsible(“collapse”)来折叠其他.my-collaspible项目:
$('.my-collaspible').not(this).collapsible("collapse");
Working Demo
#2
1
I have no idea how that thing works, maybe messy but i added class magic :D This works like you wanted though:
我不知道那件事是如何运作的,也许是凌乱但我添加了阶级魔法:D这就像你想要的那样:
$('.my-collaspible').on('collapsibleexpand', function() {
$('.opened').each(function(){
$(this).collapsible( "collapse" );
$(this).removeClass('opened');
});
$(this).addClass('opened');
});
#1
1
You need to use .collapsible("collapse")
for collapsing other .my-collaspible
items:
您需要使用.collapsible(“collapse”)来折叠其他.my-collaspible项目:
$('.my-collaspible').not(this).collapsible("collapse");
Working Demo
#2
1
I have no idea how that thing works, maybe messy but i added class magic :D This works like you wanted though:
我不知道那件事是如何运作的,也许是凌乱但我添加了阶级魔法:D这就像你想要的那样:
$('.my-collaspible').on('collapsibleexpand', function() {
$('.opened').each(function(){
$(this).collapsible( "collapse" );
$(this).removeClass('opened');
});
$(this).addClass('opened');
});