Posted over 8 years ago. Visible to the public.

Listening to bubbling events in Prototype is easy

If you come across an (older) application that is using Prototype Archive instead of jQuery, you may often see events bound to single elements only, like this:

$('foo').observe('change', updateThings); $('bar').observe('change', updateThings); $('baz').observe('change', updateThings);

If you are calling only one method in each case, this is unnecessarily ugly. Also, when your page contents have been replaced via AJAX (like sections of a form after choosing something), those event hooks will no longer work.

Instead, just do it similar to what you know from jQuery:

document.on('change', '#foo, #bar, #baz', updateThings);

Or, just apply a nice data attribute to the form fields, and look for that in your JavaScript code:

document.on('change', '[data-requires-update]', updateThings);

If you are interested in the element that was triggered the event, simply take an event argument and look at

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).

Owner of this card:

Arne Hartherz
Last edit:
over 8 years ago
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 short-lived cookies to improve usability.
Accept or learn more