Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Add attribute to auto-expand a collapsible in a set #4697

Closed
istrasoft opened this issue Jul 13, 2012 · 6 comments
Closed

Add attribute to auto-expand a collapsible in a set #4697

istrasoft opened this issue Jul 13, 2012 · 6 comments

Comments

@istrasoft
Copy link

Along with the collapsible sets and data-collapsed attribute, it would be nice to add another attribute along the lines of

so the first / last / nth collapsible would automatically be expanded on intialization.

Sometimes the collapsibles' HTML can be generated so it may not be known which one should have the data-collapsed="false" attribute at that time.

With the collapsible also lacking a programmatic way of expanding / collapsing its contents for now (there is already another feature request for this), it is kind of problematic as it is now (v1.1.1)

@jaspermdegroot
Copy link
Contributor

@istrasoft

Actually it is already possible to programmatically expand / collapse a collapsible.

I created a sample: http://jsbin.com/umajup/5/
http://jsbin.com/umajup/5/edit

We will add examples like this to the docs with the code how to achieve it.

With possibilities to add data-collapsed="false" in the markup or use first / last / nth as selector in a function I don't think a new data-attribute is needed.

@istrasoft
Copy link
Author

Thanks for the tip ! I'll try this piece of code, even though clicking the buttons on the two pages you linked to does not do anything on Chrome / Win. I didn't know there were a collapse/expand events I could trigger because there is nothing in the documentation about those. The data-attribute had the advantage of being processed on page build though.

@jaspermdegroot
Copy link
Contributor

@istrasoft

Very strange, I just tested on Chrome/Win and all buttons work.

To be honest, I didn't know it was possible to trigger "expand" / "collapse" events either until I looked at the code because of this ticket. So, yes, we do need to add this to the docs (see #4389).

I updated the code a little bit (http://jsbin.com/umajup/7/edit#html), because setting data-collapsed to true or false is not necessary when you trigger "expand" or "collapse". That was part of my first attempt to make this work.
I also changed .live() to .on() since the first is deprecated as from jQuery 1.7.

@istrasoft
Copy link
Author

I think it's because you included a script from "localhos" on the jsbin page ;)

Thanks for the tip about the events though, I was using a trigger('click') on the '.ui-btn' child element of the collapsible (but also works triggering click on the collapsible itself obviously because of propagation.

@jaspermdegroot
Copy link
Contributor

Aiii... I grabbed a JSBin I used for something else and forgot I loaded script from localhost for that. Sorry!

http://jsbin.com/umajup/8/

@istrasoft
Copy link
Author

np, shit happens :) thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants