Posted over 1 year ago. Visible to the public. Repeats. Linked content.

Firefox cancels any JavaScript events at a fieldset[disabled]

If you try to listen to events on elements that are nested inside a <fieldset disabled>, Firefox will stop event propagation once the event reaches the fieldset. Chrome and IE/Edge will propagate events.

Since we often bind event listeners to document this can be annoying.

You could solve it by…

  • …adding event listeners on elements themselves. Note that this is terrible when you have many elements that you'd register events for.
  • …adding event listeners on a container inside the <fieldset>, around your elements.
  • …using a custom attribute, like <fieldset no-edit> and using JavaScript to disable all controls inside it. This works nicely with Unpoly compilers or Angular directives.

See jsbin for an example.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
over 1 year ago
by Besprechungs-PC
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more