backbone integration: id vs. cid

Hi,

i am about finish my integration work with backbone and webix. however i have a problem:
my model’s id is overwritten with a cid.
i.e my model has e.g. id=1234 originally and after integration it becomes like id=c50
that way i am losing my id and the software doesn’t work as intended.

how can i suppress this behavior and not lose my id value?

i need urgent help…

thanks!

i think here lies the source of my problem: (webix_debug.js)

if (window.Backbone)
  (function(){
      var cfg = {
           use_id : false
  };

The sync can work in two modes

a) it uses cid from collection as id in the webix API
b) it uses the id of object as id in the webix API

Default mode is (a), but you can use mode (b) by using

some.sync(collection, { use_id: true });

Still, the id of records in the synced backbone collection must not be corrupted. Webix components makes copy of all data, to preserve original collection intact, and during data saving “id” attribute is not saved back in the original collection.

Please confirm that you have corruption of id in the original model, not the id which was obtained by webix API. I will double-check code in such case.

Mode (a) is default, because in other case webix components will need to set “id” attribute for the new records, and it will break data saving through backbone ( backbone expects null id for the new records ).

hi maksim, thank you for your quick response.

i am afraid webix corrupts my model.

this line:
this.root.sync(this.model, { use_id: true });
doesn’t help really.

but that helps:
if (window.Backbone)
(function(){
var cfg = {
use_id : true
};

There was an error in the sync code, you can grab the update build ( https://s3.amazonaws.com/uploads.hipchat.com/15721/61242/YBe6dbSdkr0LuPJ/webix_1.4.2.zip ) With it

this.root.sync(this.model, { use_id: true });

will work as expected.

I have double checked the code and still don’t see how events from the webix views can corrupt attributes of collection. Check the next sample http://webix.com/snippet/b869fdd8

You can edit data in grid, and record will be updated in the collection, but id will stay not changed.