I have 3 forms on 3 different tabs that are binded to a datatable. It works fine except when i
unbind all 3 and move from tab to tab, the initially non visible tabs throws an error when i move to the tab.
// this is basically what i am doing
var grid = $$(search.gridId);
grid.attachEvent("onBeforeSelect",
function (obj) {
$$("mainView").bind(grid);
$$("metaView").bind(grid);
$$("lastActionView").bind(grid);
}
);
//for new entries unbinding the datatable
//without an unbind, non visible textfields by default takes the bind values //when they are shown.
var newEntry = function () {
var grid = $$(search.gridId);
grid.unbind();
$$("mainView").unbind(grid);
$$("metaView").unbind(grid);
$$("lastActionView").unbind(grid);
helper.enableAllControls(false); //disable edit/delete/approve/reject controls
editor.enableFields();
editor.newFields();
meta.newFields();
lastAction.newFields();
enableSaveButton(true);
};
the source of the error is on line 3817 of webix_debug.js - function getBindData
this._bind_update(target, this._bind_hash[key][0], this._bind_hash[key][1]);
It appears even if the targets are unbinded, the tab visibility toggle still tries to update the bind values
sometimes this._bind_hash[key] is null or sometimes this._bind_hash[key] length is zero. hence it throws an error.
The below modification with a null check and length check between
//modstart and
//modend solves the issue
getBindData:function(key, update){
//fire only if we have data updates from the last time
if (this._bind_updated[key]) return false;
//MODSTART
if (!this._bind_hash[key] || this._bind_hash[key].length==0) return false;
//MODEND
var target = webix.$$(key);
//fill target only when it visible
if (target.isVisible(target._settings.id)){
this._bind_updated[key] = true;
if (webix.debug_bind)
webix.log("[bind:request] "+this.name+"@"+this._settings.id+" => "+target.name+"@"+target._settings.id);
this._bind_update(target, this._bind_hash[key][0], this._bind_hash[key][1]); //trigger component specific updating logic
if (update && target.filter)
target.refresh();
}
},
take a look at Code Snippet
Appreciate some feed back.