Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggling States Doesn't Work? #6

Closed
HughxDev opened this issue Apr 11, 2012 · 2 comments
Closed

Toggling States Doesn't Work? #6

HughxDev opened this issue Apr 11, 2012 · 2 comments

Comments

@HughxDev
Copy link

Trying to close all other details elements when one is opened, "accordion-style". Have tried this in Chrome:

$('details').details();
$('nav li > details').on('open.details', function() {
    var details = $(this);
    details.parent().siblings().find('details').details('close');
});

as well as the same with .trigger('close.details') and triggerHandler('close.details'). Is this a bug or am I doing something wrong?

@mathiasbynens
Copy link
Owner

There is no such signature as .details('close') in this plugin, so that wouldn’t work.

You want to do this: https://github.com/mathiasbynens/jquery-details/blob/541097e13a251c4d652010fd3842c75886eae980/jquery.details.js#L34-46

Note that Chrome uses a native <details> implementation, so just triggering the close.details handler is not enough — you need to call .prop('open', false).

@HughxDev
Copy link
Author

OK, thank you. Figured there would be a single method of invoking regardless of whether the behavior was native or polyfilled—obviously, this solution is simple enough, but I’d like to propose that feature, as a compliment to toggleOpen.

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

No branches or pull requests

2 participants