I am currently working on syncing my backbone model with webix tabletree.
calling sync like this:
afterRender: function () {
this.root.sync(this.collection);
}
that approach fails to call backbone sync method, because (as far as i could understand through debugging webix_debug.js) because this code below doesn’t have any mapping (_evs_map is empty):
if (this._evs_map[type]){
var target = this._evs_map[type];
target.$eventSource = this;
if (!target.callEvent(type,params))
return_value = false;
target.$eventSource = null;
}
any ideas?
syncing is the most important part of my integration work (webix <-> backbone)
In above sample, is the this.root - points to the webix view and this.collection to some assigned Backbone collection ?
In such case this.root.sync(this.collection); will load data from collection into the webix.view ( to be correct it will create a constant link between collection and view, each time when data changed in collection, view will update itself accordingly ). Webix will not call collection.fetch or collection.sync, it will use an existing data ( or, if collection is empty, will wait for data loading )
When data changed in the webix view ( you are using editor in the grid for example ), data in backbone collection will be updated, but related model will not be saved to server. ( so again there is no backbone sync call ) You can use events to trigger data saving.
Webix-Backbone integration was created in such way to prevent any automatic calls to server side. Do you expect some other behavior ?
i expect exactly what you described. sync method should create a constant link. but in my case it doesn’t even load data to my treetable. i see an empty treetable and no error messages.
and yes, this.root is a webixView and this.collection is the collection.
i assume that webix should call some sync methods of backbone.js behind the curtains. and as far as i could debug, the code block that should do this is the part i pasted above.
In my case this code block is not reachable because the if statement gets a false, since _evs_map is empty.
i am just trying to think logically and isolate the problem and find out why the data is not loaded into my treetable.
since its really complex code, i cannot transform it to a snippet form, sorry.
_evs_map is related to the events processing in webix components, in some cases event which starts in one component must be routed to another. _evs_map contains the routing map.
It seems that problem was a much more simple. The sync command was setting the correct event handler, but did not start the real syncing, it was waiting for the activity from the backbone collection. It worked for our samples, but may not work in some other cases, where data is fully loaded in collection at the “sync” moment.