Closed
Description
if have some relation:
models.Task = Backbone.RelationalModel.extend({ relations: [ { type: Backbone.HasOne, key: 'scaner', relatedModel: 'models.Tool' } ] });
and a have three scanner models with ids 0,1 and 2
Code work perfect if id > 0, and don't work, if id === 0
I find code of function "findRelated" in Backbone-relational and change it:
findRelated: function( options ) { var item = this.keyContents; console.log(item); var model = null; if ( item instanceof this.relatedModel ) { model = item; } else if ( item || item === 0 ) { //add null check model = this.relatedModel.findOrCreate( item, { create: this.options.createModels } ); } return model; }
Can you append my fix or another solution for fix bug, when id === 0?
Metadata
Assignees
Labels
No labels