2013-10-14 60 views
0

我的頁面上有以下可摺疊標題,當前您點擊它展開和摺疊的設置。我想要的是當你點擊列表項中的一個而不是回到頂部來摺疊它時,javascript會使集合崩潰。這可能嗎?可摺疊套裝jquery

<div data-role="collapsible" class="ui-collapsible-collapsed ui-block-a" id="my-collapsible"> 

       <h2> 
       <a href="#111" class="ui-collapsible-heading-toggle ui-btn ui-btn-up-c" data-corners="false" data-shadow="false" data-wrapperels="span" data-icon="false" data-theme="c"> 

       </a> 
       </h2> 
       <div class="ui-collapsible-content ui-body-c ui-collapsible-content-collapsed" aria-hidden="true"> 
        <ul data-role="listview" data-theme="g"> 

         <li id="topnav4"><a id="tempshellstempb" onclick='changeshellsb();'></a></li> 
         <li id="topnav4"><a id="tempstarstempb" onclick='changestarsb();' ></a></li> 
         <li id="topnav4"><a id="temppeacocktempb" onclick='changeIt();'></a></li> 
         <li id="topnav4"><a id="tempshootstarsb" onclick='changechestb();'></a></li> 
         <li id="topnav4"><a id="tempbrickstempb" onclick='changerosesb();'></a></li> 
         <li id="topnav4"><a id="tempforresttempb" onclick='changepeacockb();'></a></li> 

        </ul> 

       </div></div> 
+0

你能創建一個http://jsfiddle.net/來展示這個問題嗎? – Trevor

+0

@trevor它不是一個真正的問題,只是一個關於如何使列表項在點擊時摺疊集的問題。當您單擊標題時,它會摺疊並展開內容,但當您單擊 Steven

+0

@Steven,我也希望它摺疊,因此您希望它通過單擊任何項​​目或元素來展開和摺疊在崩潰的div?是的,這是可能的,哪個插件目前正在處理你的崩潰?你要離開這個插件嗎? http://jquerymobile.com/demos/1.1.1/docs/content/content-collapsible-set.html – ermagana

回答

1

使用jQuery,你可以觸發崩潰。

$('#tempshellstempb').click(function(){ 
    //here you probably want to check to see if your selector is currently collapsed to decide whether your going to collapse or expand. 
    // you can probably do this by checking the classes on your selector but i'm not too familiar with how jQuery-mobile handles this 
    $(".selector").trigger("collapse"); 
    //$(".selector").trigger("expand"); 
}); 
+0

@Steven如果回答您的問題,請將此答案標記爲已接受,否則請提供有關未解決問題的反饋。謝謝 – Trevor