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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -