Cannot read property 'on' of undefined

1958
1
12-11-2017 05:23 PM
EllaHaines
New Contributor III

I basically copied one of ESRI's samples with the intention of modifying it. However, it doesn't seem to recognize the "on" in the "require" statement. I'm not sure what I'm doing wrong here.

Console error: 

TypeError: Cannot read property 'on' of undefined
at l (init.js:122)
at symbology-picker.js:48

symbology-picker.js:

require([
"dojo/parser",
"dojo/ready",
"dojo/dom",
"dojo/dom-construct",
"dojo/_base/array",
"dojo/_base/json",
"dijit/registry",
"dojo/on",
"dojo/_base/connect",
"esri/dijit/editing/TemplatePicker",
"esri/arcgis/Portal",
"esri/domUtils",
"esri/config",
"esri/request",
"esri/symbols/jsonUtils",
"esri/symbols/Symbol",
"esri/lang",
"dojo/store/Memory",
"dijit/form/ComboBox",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane"
], function (
parser,
ready,
dom,
domConstruct,
array,
dojoJson,
registry,
on,
connect,
TemplatePicker,
arcgisPortal,
domUtils,
config,
esriRequest,
jsonUtils,
Symbol,
esriLang,
Memory
) {
var templatePicker, store;
ready(function () {
   parser.parse();

   var portalUrl = document.location.protocol + "//www.arcgis.com";
   on(registry.byId("symbolList"), "change", updateSymbolDisplay); //<-- erroring here

   ...(more code)

});

in my scripts section:

<script src="https://js.arcgis.com/3.22/"></script>
<script src="~/Scripts/symbology-picker.js"></script>

Sample: ArcGIS API for JavaScript Sandbox 

The only idea I have right now is maybe some sort of conflict with jQuery, but we are using it successfully in other parts of our project which include a map page.

If I were to call "on" using its class, how would I do that? "dojo.on()" doesn't seem to work.

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Esteemed Contributor

Ella,

   That error does not mean you are having an issue with dojo/on it means that you are not finding the target object that you want to person the on on.

registry.byId("symbolList")

Is what is returning undefined.