Select to view content in your preferred language

ReferenceError: event is not defined

3689
2
Jump to solution
12-27-2018 02:04 PM
JaredPilbeam2
MVP Regular Contributor

Will County Attractions 

I have an app that works as it should in Chrome and IE. In FireFox it doesn't.

The error in the console is pointing to a specific line (line 2:15 here) of the html:

        attTypeSelect.addEventListener("change", function () {
          var type = event.target.value;
          setattractionsDefinitionExpression(type);
        });

Here's what is (or isn't) happening:

When you choose a Type from the dropdown menu it will not populate on the map. 

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jared,

  I always use dojo/on for this:

        // set a new definitionExpression on the attractions layer
        on(attTypeSelect, "change", function (event) {
          var type = event.target.value;
          setattractionsDefinitionExpression(type);
        });

I tested in FireFox and it works fine.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Jared,

  I always use dojo/on for this:

        // set a new definitionExpression on the attractions layer
        on(attTypeSelect, "change", function (event) {
          var type = event.target.value;
          setattractionsDefinitionExpression(type);
        });

I tested in FireFox and it works fine.

Noah-Sager
Esri Regular Contributor

Jared Pilbeam the code that Robert provided is fine, but if you don't want to use the dojo/on (which we have been removing from our samples to reduce dependencies), you could do a similar thing by just passing the event in the unnamed function. This also works fine across browsers, including Firefox. What is surprising is that Chrome and IE were smart enough to determine what the value of event was supposed to be.