bind

binds a function to an object

function bind(function code,object master);
codefunctionthe function that will be bound
masterobjectthe object which the function will be bound to
functionthe bound function

Example

var grid = webix.ui({
    view:"datatable", 
    on:{
        "onStoreUpdated":webix.bind(this.render, this)
    }
});
//'this' refers to a datatable object

Details

Inside the function the this keyword becomes a reference to the object scope.

Function and component binding works as well during attaching the function with an attachEvent method:

grid.attachEvent("onStoreUpdated", webix.bind(this.render, this)); 
//'this' is still a grid object since attachEvent() is called from it
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.