Adding EventListeners for UiKit events in Scalajs React

608 views Asked by At

I am using this code form:

dom.document.getElementById("contents").addEventListener("click", {
  (e0: dom.Event) => println("Got the click event at top level!")
}, false)

To experiment with event capturing in Reactjs. This works fine for the click event. However, when trying to do the same thing with UIKit events for the nestable component, as below:

dom.document.getElementById("contents").addEventListener("start.uk.nestable", {
  (e0: dom.Event) => println("Got the start event at top level!")
}, false)

I am not getting anything. The nestable documentation lists four event names and I've tried all of them - but never get any response when manipulating nestables. It is my understanding that without capture the events should be bubbling up to the top level where the listener is attached; but when using devtools to monitor events on the entire document it seems like the nestable events are not fired.

Incorrect event type? Incorrect event name? UiKit swallowing its own events for some reason? Thankful for any help.

1

There are 1 answers

0
Greg On

Apparently this is a consequence of UIKit's reliance on using jquery's .trigger() to send its custom events, which cannot normally be listened to except through jquery as per this bug report:

https://bugs.jquery.com/ticket/11047

This being the case I took to manually adding jquery listeners in my page setup and calling back into the Scalajs code through the normal @JSExport method.