Select to view content in your preferred language

Do the items in the require([...] have to be in specific order, or do some conflict with each other?

4813
4
02-04-2015 03:49 PM
MitchellOttesen
Deactivated User

I'm new to the Javascript API.

 

An example of my question is if you add "esri/Symbols/SimpleLineSymbol" to the list on this sample: ArcGIS API for JavaScript Sandbox

 

It will lose functionality. Why is that?

0 Kudos
4 Replies
OwenEarley
Frequent Contributor

The items do not have to be in any order. However, the order needs to be reflected in the names of the function parameters:

requires.png

The case of the required module path matters. In your example try changing "esri/Symbols/SimpleLineSymbol"  to "esri/symbols/SimpleLineSymbol" (note the lowercase s in /symbols/).

ChrisSergent
Deactivated User

I agree with Owen, but you should put your require statements that do not have parameters last as this will put your required elements and your parameters out of order.

KenBuja
MVP Esteemed Contributor

Take a look at this informative blog post on the basics of AMD programming.

The most important thing to remember is that the arguments are positional, which means that you have to be careful to ensure that your argument names are listed in the same order that you loaded your modules.  If this isn’t done your variables won’t refer to the module you expect them to.

You will also see that sometimes AMD samples load modules that weren’t loaded using dojo.require() before.  Some examples are: “esri/config”, “dojo/_base/Color”, and “dojo/dom”.

TimWitt2
MVP Alum

Mitchell,

Check out the new tool I have created: Get your map!

Once you got your extent and basemap click on "Go to require", which will take you to a require builder, which was first created by Derek Swingley  . I did some debugging on his code and included it in my tool.

Let me know if this helps!

Tim