Skip to content

How to: Stop listening to events

Mendel Kramer edited this page Feb 8, 2018 · 2 revisions

Based on discussion here: #805

If you want to stop listening to a specified event, it's possible to name the events to stop listening to.

ReactRailsUJS.removeEvent('turbolinks:render', ReactRailsUJS.handleMount);
ReactRailsUJS.removeEvent('DOMContentLoaded', ReactRailsUJS.handleMount);
$(window).on('load', function() {
  ReactRailsUJS.handleMount();
  ReactRailsUJS.detectEvents();
})

Thanks @anaumov