javascript - How to use Composite Keys for Backbone Model -
define([ 'backbone' ], function(backbone) { var model = basemodel.extend({ urlroot:"/api/v1/processinggroups/version/step/param", idattribute: 'extparamid', initialize: function(model, options) { var defaults; if (typeof model === "undefined") { defaults = { "businessid": null, "extparamid": null, "pgstepname": null, "extprocname": null, "extparamname": null, }; } this.set(defaults); }, }); return processgrpexternalparamsmodel;
});
this model using. want idattribute combination of 2 values like
idattribute: 'extparamid' , "businessid"
or
idattribute: extparamid + "-" + businessid
is possible achieve this. how achieve this
you can try set within constructor
var model = basemodel.extend({ constructor: function(model) { this.idattribute = model.extparamid + '-' + model.businessid; } });
Comments
Post a Comment