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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -