Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collapsible Content in jquery mobile

I have a simple collapsible content element at the top of a page that has a list view. The html works fine.

My problem is that if a user opens the collapsible block, I'd like it to automatically close when the user leaves or comes back to the page. The collapsible block always remains as the user has left it--open. I don't know how to close it. I've searched for a couple of days, but can't find the exact scenario. Most of the solutions that I've found deal with dynamic loading of pages and they are a little too advanced for me to understand.

I know this is probably a simple thing, but I'm so new to jquery mobile. I don't know how to bind the code to the html element or where to put it so please work me though with baby steps.

Does anyone know how to do this?

like image 470
user1204493 Avatar asked Dec 22 '25 23:12

user1204493


1 Answers

Hi in my jqm web app I close programmatically collapsible block like this:

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

You should bind pageshow event like this :

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

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

       });  

for example you can try this jsFiddle

like image 55
Yann86 Avatar answered Dec 30 '25 02:12

Yann86



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!