Read more

Firefox cancels any JavaScript events at a fieldset[disabled]

Arne Hartherz
November 07, 2017Software engineer at makandra GmbH

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.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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 Show archive.org snapshot for an example.

Posted by Arne Hartherz to makandra dev (2017-11-07 18:24)