AtomRender¶
-
class
webix.
AtomRender
()¶ Atomrender mixin
References¶
- helpers
bind()
,log()
,template()
.
Referenced by¶
- components
SingleRender()
.- views
button()
,template()
.
External references¶
Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | webix.AtomRender={
//convert item to the HTML text
_toHTML:function(obj){
if (obj.$empty )
return "";
return this._settings.template(obj, this);
},
//render self, by templating data object
render:function(){
var cfg = this._settings;
if (this.isVisible(cfg.id)){
if (webix.debug_render)
webix.log("Render: "+this.name+"@"+cfg.id);
if (!this.callEvent || this.callEvent("onBeforeRender",[this.data])){
if (this.data && !cfg.content){
//it is critical to have this as two commands
//its prevent destruction race in Chrome
this._dataobj.innerHTML = "";
this._dataobj.innerHTML = this._toHTML(this.data);
}
if (this.callEvent) this.callEvent("onAfterRender",[]);
}
return true;
}
return false;
},
sync:function(source){
this._backbone_sync = false;
if (source.name != "DataStore"){
if (source.data && source.name == "DataStore"){
source = source.data;
} else {
this._backbone_sync = true;
}
}
if (this._backbone_sync)
source.bind("change", webix.bind(function(data){
if (data.id == this.data.id){
this.data = data.attributes;
this.refresh();
}
}, this));
else
source.attachEvent("onStoreUpdated", webix.bind(function(id){
if (!id || id == this.data.id){
this.data = source.pull[id];
this.refresh();
}
}, this));
},
template_setter:webix.template
};
|