registry is not defined

2669
8
Jump to solution
02-29-2016 04:32 PM
LefterisKoumis
Regular Contributor

I am writing a code too fill combo box values to a form but I encounter the error that the registry is not defined even though it has been defined on line 40... Suggestions? Thank you.

require([ "dojo/ready", 
        "dojo/on",
        "dojo/_base/connect", 
        "dojo/dom",
        "dijit/registry",
        "dojo/dom-construct",
        "dojo/parser", 
        "esri/arcgis/utils",
        "esri/domUtils",      
  "esri/tasks/query", 'dijit/_WidgetsInTemplateMixin',
'dojox/xml/parser', 'dojox/data/XmlStore',
'esri/tasks/QueryTask',"dijit/Menu", 
    "dijit/MenuItem",'dijit/form/Select',
  "dojo/domReady!"], function(
  ready, 
        on, 
        connect,
        dom,
        registry,
        domConstruct,
        parser, 
        arcgisUtils,
        domUtils,
  Query, _WidgetsInTemplateMixin, parser, 
  xmlParser, XmlStore,
  QueryTask, Menu, MenuItem, Select
  ){


  parser.parse();
  fillcountyselect();
  });


  


   function fillcountyselect(){
   
    var select1 = registry.byId("countyfield");
  select1.addOption( {label:"Select County", value: 0});
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor

You also have a problem with your require modules/function arguments agreement. You have an extra "parcer" here:

_WidgetsInTemplateMixin, parser,  xmlParser

View solution in original post

8 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Lefteris,


  It looks like your combo fill function is outside your main function thus unreachable


0 Kudos
MiriamBrockmann
Occasional Contributor

Hello Lefteris,

Robert is right. Your function and the call for the registry.byId lies outside the above defined require.

If you set it up it like this :

function fillcountyselect(){  

     require(["dijit/registry"],function(registry){    

          var select1 = registry.byId("countyfield"); 

          select1.addOption( {label:"Select County", value: 0});

          ....u.s.o.

     });

}

you have access to "registry".

Regards

0 Kudos
LefterisKoumis
Regular Contributor

Thank you Miriam.

I still get a message that the "Cannot read property 'addOption' of undefined". It seems that the registry is still not recognized.

This is from the html.

  <select style="margin-top:10px;margin-bottom:10px;" id="countyfield" data-dojo-attach-point="countyfield" data-dojo-type="dijit/form/Select" data-dojo-attach-event="onChange:_onCountyClick"></select>

0 Kudos
KenBuja
MVP Honored Contributor

You also have a problem with your require modules/function arguments agreement. You have an extra "parcer" here:

_WidgetsInTemplateMixin, parser,  xmlParser

LefterisKoumis
Regular Contributor

One of my select is populated by an xml file. So, using just  xmlparser will be sufficient for the whole form?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Lefteris,

   No Ken is talking about the fact that you have "parser" listed twice and xmlParser once.

on,connect,dom,registry,domConstruct,parser,arcgisUtils,domUtils,Query, _WidgetsInTemplateMixin, parser,xmlParser, XmlStore,QueryTask, Menu, MenuItem, Select

0 Kudos
LefterisKoumis
Regular Contributor

I need to have my eyes checked. How much time did I wasted for this! #$@$

Thank you all!

AZendel
Occasional Contributor III

I ran across this post when I was also getting an undefined variable after using 

var myVar = registry.ById("myDIV);
 
My problem was that I hadn't used parse.parse() at the very top of the code in the main "function", like in this example. Just thought I'd mention this in hope that it'll save someone some time!
0 Kudos