Com.atlassian.auiplugin:aui-toggle event issue

I have declared a aui-toggle element in my soy file

<aui-toggle id="date-type-select" label="Date Type"></aui-toggle>

and in my js I retrieve the toggle object

var $toggle =  $(".date-type-select", $form);

I tried using “document.getElementById” as mentioned in the AUI document pages but that would not work (null).

I then attempted to add a listener also as shown in the official docs:

toggle.addEventListener(`

But this throws a “.addEventlistener is not a function”. So instead I uses .click which does work.

$toggle.click(_.bind(function() {

Why is this? Why do the docs say to use “.addEventListener”? And their codepen example works!

Reference: https://docs.atlassian.com/aui/8.0.2/docs/toggle-button.html

In case anyone else comes looking. The answer is here:

https://stackoverflow.com/questions/55732045/uncaught-typeerrorbutton-addeventlistener-is-not-a-function