extend

merges the contents of 2 objects together into the first object

object extend(object target,object source, [boolean overwrite] );
targetobjectthe object to extend. It receives the new properties
sourceobjectan object that contains properties to merge in
overwritebooleanif the value is true, the same properties will be overwritten by the values of the source object
objectthe target object with the new properties

Example

var obj1 = {name:"flower", type:"rose", colors: ['red','pink','white','yellow']};
var obj2 = {name:"flower", type:"tulip" };
 
webix.extend(obj2,obj1); 
// -> obj2 = {name:"flower", type:"tulip", colors: ['red','pink','white','yellow']}
 
 
var button = {
    view:"button", width:200, value:"Remove",
    css:"webix_danger"
};
var button2 = webix.extend({
    type:"icon", icon:"wxi-pencil"
}, button);
// different buttons
webix.ui({
    cols:[
        button, button2
    ]
});

Details

Most commonly, the method is used for extending the functionality of widgets with mixins:

webix.extend($$("grid"), webix.ProgressBar);

The extend method can mix the properties of the source into the target:

webix.extend(target, source);

It can also return a new object, leaving the target as is, if you copy the target:

webix.extend(webix.copy(target), source);

You can rewrite the properties in the target with the same-name properties of the source. Pass true as the third parameter of extend():

webix.extend(target, source, true);
See also
Back to top