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