This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22942 - We should fire onopen and onclose when <details> is opened and closed.
Summary: We should fire onopen and onclose when <details> is opened and closed.
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-13 20:45 UTC by contributor
Modified: 2013-11-06 19:13 UTC (History)
4 users (show)

See Also:


Attachments

Description contributor 2013-08-13 20:45:45 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#attr-details-open
Complete: http://www.whatwg.org/c#attr-details-open
Referrer: http://xn--74h.damowmow.com/

Comment:
We should fire onopen and onclose when <details> is opened and closed.

Posted from: 2620:0:1000:167c:55e0:acbd:8909:3cd8 by ian@hixie.ch
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1588.0 Safari/537.36
Comment 1 Domenic Denicola 2013-09-04 18:36:51 UTC
I don't have a strong opinion on this, but after consulting with a coworker he prefers one event instead of two. The rationale being that it's easier to bind to a single event with existing client-side frameworks (e.g. Backbone), and then use the boolean value it would give you to e.g. toggle classes:

Backbone.View.extend({
  events: {
    'toggle details.my-details': function (ev) {
      this.$('.related-thing-to-toggle').toggleClass('active', ev.target.open);
    }
  }
});
Comment 2 Ian 'Hixie' Hickson 2013-09-04 19:08:26 UTC
So a single event, but fire it after the state has changed. That makes sense.

ontoggle="" is ok, but not ideal. Anyone got a better colour for this shed?
Comment 3 Ian 'Hixie' Hickson 2013-11-06 18:11:43 UTC
I went with 'toggle' as suggested.

Checked in as WHATWG revision r8251.
Check-in comment: <details ontoggle=''> for when you open or close a <dialog>.
http://html5.org/tools/web-apps-tracker?from=8250&to=8251
Comment 4 contributor 2013-11-06 19:13:27 UTC
Checked in as WHATWG revision r8252.
Check-in comment: ack for last checkin
http://html5.org/tools/web-apps-tracker?from=8251&to=8252