- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)
- Eric Pimpler Mark Lewin
- 260字
- 2021-07-02 15:48:58
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.
- Web應用系統開發實踐(C#)
- Learning Python Design Patterns(Second Edition)
- Data Analysis with Stata
- 零基礎學單片機C語言程序設計
- 深度學習:Java語言實現
- 微服務從小白到專家:Spring Cloud和Kubernetes實戰
- Building Machine Learning Systems with Python(Second Edition)
- Learning AWS
- Java圖像處理:基于OpenCV與JVM
- 創意UI:Photoshop玩轉APP設計
- 跟戴銘學iOS編程:理順核心知識點
- Mastering OAuth 2.0
- Redmine Cookbook
- 3D Printing Designs:Octopus Pencil Holder
- Learning D3.js 5 Mapping(Second Edition)