You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,6 +310,19 @@ ReactRailsUJS.detectEvents()
310
310
311
311
For example, if `Turbolinks` is loaded _after_`ReactRailsUJS`, you'll need to call this again. This function removes previous handlers before adding new ones, so it's safe to call as often as needed.
312
312
313
+
If `Turbolinks` is `import`ed via Webpacker (and thus not available globally), `ReactRailsUJS` will be unable to locate it. To fix this, you can temporarily add it to the global namespace:
314
+
315
+
```js
316
+
// Order is particular. First start Turbolinks:
317
+
Turbolinks.start();
318
+
// Add Turbolinks to the global namespace:
319
+
window.Turbolinks= Turbolinks;
320
+
// Remove previous event handlers and add new ones:
321
+
ReactRailsUJS.detectEvents();
322
+
// (Optional) Clean up global namespace:
323
+
deletewindow.Turbolinks;
324
+
```
325
+
313
326
### `getConstructor`
314
327
315
328
Components are loaded with `ReactRailsUJS.getConstructor(className)`. This function has two built-in implementations:
0 commit comments