ready

dojo/ready

Summary

Add a function to execute on DOM content loaded and all requested modules have arrived and been evaluated. In most cases, the domReady plug-in should suffice and this method should not be needed.

When called in a non-browser environment, just checks that all requested modules have arrived and been evaluated.

Usage

ready(priority,context,callback);
Parameter Type Description
priority Integer
Optional

The order in which to exec this callback relative to other callbacks, defaults to 1000

context undefined

The context in which to run execute callback, or a callback if not using context

callback Function
Optional

The function to execute.

See the dojo/ready reference documentation for more information.

Examples

Example 1

Simple DOM and Modules ready syntax

require(["dojo/ready"], function(ready){
    ready(function(){ alert("Dom ready!"); });
});

Example 2

Using a priority

require(["dojo/ready"], function(ready){
    ready(2, function(){ alert("low priority ready!"); })
});

Example 3

Using context

require(["dojo/ready"], function(ready){
    ready(foo, function(){
        // in here, this == foo
    });
});

Example 4

Using dojo/hitch style args:

require(["dojo/ready"], function(ready){
    var foo = { dojoReady: function(){ console.warn(this, "dojo dom and modules ready."); } };
    ready(foo, "dojoReady");
});

Methods

© 2005–2015 The Dojo Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/ready.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部