Looking at examples and seeing two different ways to require dojo. Whats the difference and which one should I be using? Sorry for the green question...
The second way (AMD) is the direction that Dojo and Esri's JSAPI are going. The first way (legacy) will eventually be deprecated when Dojo 2.0 is realeased. Take a look at this help page.
The second way (AMD) is the direction that Dojo and Esri's JSAPI are going. The first way (legacy) will eventually be deprecated when Dojo 2.0 is realeased. Take a look at this help page.
Imagine I have another script on the page that needs to call a function inside the require(). None of the functions inside require() are visible outside of it.
For instance, let's say I already have the point or x,y and simply want to map it. If the code with the xys is outside the require(), how can I get the points mapped?
You would create separate modules to keep your code modular. Here's a diagram I have been using to kind of explain how require/define work together a little easier for people. [ATTACH=CONFIG]31596[/ATTACH]
So you could have a module that somehow produces your coordinates, and can return them via a pattern like the revealing module pattern in the module.
You can then call the module from your the methods inside the require() of your application.
Every Dojo app needs at least one require() method, but can have multiple modules using define().