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.
- 深入核心的敏捷開發(fā):ThoughtWorks五大關鍵實踐
- ASP.NET MVC4框架揭秘
- GeoServer Cookbook
- Responsive Web Design with HTML5 and CSS3
- Java加密與解密的藝術(第2版)
- Getting Started with PowerShell
- DevOps Automation Cookbook
- Access 2010數據庫基礎與應用項目式教程(第3版)
- Flash CS6中文版應用教程(第三版)
- Python機器學習:手把手教你掌握150個精彩案例(微課視頻版)
- 微信小程序入門指南
- Java Web開發(fā)詳解
- 打開Go語言之門:入門、實戰(zhàn)與進階
- Extreme C
- 實戰(zhàn)Java高并發(fā)程序設計(第2版)