I have a problem while initializing a Backbone model with some data coming from Jackson
.
The received data happens to have a listPropertyValue
, which is originally a Java List
of objects. When doing the initialize()
method I make it a Backbone collection without much problem.
But the final SomeModel
constructor also adds an attribute called listPropertyValue
as a JavaScript array, which I don't want.
How may I discard or reject this array and which is the right way to do it?
Here is my code:
var SomeModel = Backbone.Model.extend({
defaults : {
id:null,
name:'',
order:null,
isRequired:null,
}
initialize : function(options) {
if(options.listPropertyValue !== undefined) {
this.set('collectionPropertyValue', new PropertyValueCollection(options.listPropertyValue))
}
// I thought of doing this. Don't know if it's the right thing to do
// this.unset('listPropertyValue', { silent: true });
}
My concern is not only how to do it, but how to do it in a proper Backbone way.