您可以绑定到元素的expand
事件,然后collapse
在其余可折叠项上触发事件:
//since we don't know when the page will be injected into the DOM,
//we can bind to it's elements once it's been added to the DOM and is about to be initialized
$(document).delegate('#my-page-id', 'pageinit', function () {
//cache each of the collapsible elements in a variable
var $collapse = $(this).find('[data-role="collapsible"]');
//bind to each collapsible's `expand` event
$collapse.bind('expand', function () {
//when a collapsible is expanded, collapse all the others on this page
$collapse.not(this).trigger('collapse');
});
});
这是一个演示:http: //jsfiddle.net/FhZVn/