Making sure the DOM is available
When a web page loads, all the HTML elements that comprise the page are loaded and interpreted. This is known as the DOM (Document Object Model). Your JavaScript must not attempt to access any of these elements until all the elements have loaded. Obviously if your JavaScript code attempts to access an element that hasn't been loaded it will cause an error. To control this, Dojo has a ready() function that you can include inside the require() function, which will execute only after all the HTML elements and any modules have loaded. Alternatively, you can use the dojo/domReady! plugin to ensure that all the HTML elements have been loaded. We'll use the second method here:
<script> require(["esri/map", "dojo/domReady!"], function(Map) { }); </script>
Note that, even though we have included the dojo/domReady! module in the list of modules we want to load, we have not provided an alias for it. This is because although we need the plugin to inform the application that the DOM is ready, we don't need to refer to it explicitly in our code. This is the exception to the rule we mentioned earlier.
- R語言數(shù)據(jù)分析從入門到精通
- LabVIEW程序設(shè)計基礎(chǔ)與應(yīng)用
- INSTANT Weka How-to
- 前端架構(gòu):從入門到微前端
- Mastering Ubuntu Server
- Oracle Database 12c Security Cookbook
- BIM概論及Revit精講
- Scala Reactive Programming
- HTML5+CSS3 Web前端開發(fā)技術(shù)(第2版)
- 計算機應(yīng)用技能實訓(xùn)教程
- QPanda量子計算編程
- 貫通Tomcat開發(fā)
- C語言程序設(shè)計
- OpenCV 3.0 Computer Vision with Java
- After Effects CC技術(shù)大全