Collapsible content in jQuery mobile

I have a simple collapsible content element at the top of the page with a list view. Html works fine.

My problem is that if the user opens the assembly block, I would like it to automatically close when the user leaves or returns to the page. A folding unit always remains when the user leaves it - open. I do not know how to close it. I searched for a couple of days, but can not find the exact script. Most of the solutions I have found deal with dynamic page loading, and for me this is too hard to understand.

I know this is probably a simple thing, but I'm so new to jQuery mobile. I don’t know how to attach the code to the html element or where to put it, so please help me though with the kids.

Does anyone know how to do this?

+3
source share
2 answers

Hi in my jqm web application, I close the soft reset block as follows:

$ ('-collapsible') trigger ('collapse') ;.

You must link the event to the page:

$('#your_page_id').bind('pageshow', function(){

            $('.ui-collapsible').trigger('collapse');

       });  

for example you can try this jsFiddle

+5
source

this works with jQM 1.4:

$('#yourdivId').collapsible('collapse');

You can do the following:

$(document).on("pageshow", "#yourpageId", function () {
  $('#yourdivId').collapsible('collapse');
})
+1
source

All Articles