Skip to main content

enode.ready()

When an enode is lazy-loading, this method will register a callback function to be invoked after enode is fully loaded and ready.

In fact, most of built-in methods of enode use ready() under their implementation, only some methods that do not care if the enode is ready or not, e.g. enode.when().

Therefore, the main usage of this method is when accessing the associated HTML element via enode.element and using its native web APIs. In such case, we need to verify if the lazy-loading enode is ready before doing any further process.

Syntax

JavaScript
enode.ready(callback: Function)

Parameters

callback(enode: Binh.ElementNode)

  • When the enode is ready, the callback function will be invoked with that enode as parameter.

Return value

The current enode, ready for the chaining method calls.

Examples

JavaScript
var content = Binh.ui('/web/components/UIComponent.js');

content.ready(function(content) {
var elementWidth = content.element.offsetWidth;
// code...
});

Binh.ui('/web/components/UIComponent2.js').ready(function(content2) {
var elementWidth2 = content2.element.offsetWidth;
// code...
});