Select to view content in your preferred language

JS API 3.4 how to use dojo?

937
2
07-16-2013 05:03 AM
UldisGitendorfs
Deactivated User
I do not understand how and when to use

require([
        "dojo/_base/connect",
        etc.],
        function(connect) {
          });
and when
dojo.require();

I have tried to use require([]) ... but nothing works.
Do I have to use this before any function???

Are there any extended examples on the net?
0 Kudos
2 Replies
JeffJacobson
Frequent Contributor
Don't use dojo.require().  That is the old way to do things. You should use the AMD method for new development.

Here is a sample on JSFiddle. Here's the same sample on Plunker.
0 Kudos
JonathanUihlein
Esri Regular Contributor
Thanks for posting a sample Jeff. His sample is adapted from this tutorial:
https://developers.arcgis.com/en/javascript/jstutorials/intro_firstmap_amd.html


This link goes over the new AMD style using require:
https://developers.arcgis.com/en/javascript/jshelp/whats_new.html
0 Kudos