I am using backbone.js for creating an application. I have code JS code as follows,
window.RequestsView = Backbone.View.extend({
initialize:function ( input ) {
console.log('input ' + JSON.stringify(input) );
this.variables = { request_id:input.model.id,
status:input.model.status,
mavenGav:input.model.mavenGav,
email:input.model.emailId,
errorNo:input.model.errorNo,
errorDesc:input.model.errorDesc };
console.log("variables : "+ JSON.stringify( this.variables ) );
this.template = _.template(tpl.get('requests'));
var out = this.template( input );
console.log("out: "+ JSON.stringify( out ) );
// deep copy the object
this.request = $.extend( true, {}, input);
}
});
When I debug this in chrome debugger, I get the following logs,
input {"model":{"mavenGav":"fgdfgfdgdfg:fgdfgfd:gdfgdfg","repositories":["dfgdfgdfgf"],"emailId":"gdfg","id":1083,"createdTime":null,"status":"CREATED","errorNo":0,"errorDesc":null}}
requests.js:12variables : {"request_id":1083}
There are no errors. What happens to the rest of the javascript literal that got assigned to this.variables ?
undefinedvalues are not stringified to json, because json only knows numbers, strings, booleans, null and objects/arrays. So the properties exist, but they “get lost” in conversion.Try
console.debug("variables :",this.variables), that will let you inspect the variables object.