Right now, while I am debugging backbone or marionette using the chrome dev tools, I end up setting break points and whatnot, but once the code pauses, its hard to tell what typ
Yes. You can change the console display name by overriding a model/collection/view constructor
using a named function expression. It may also be helpul to override toString
to control the console output when the model is forced to string type with, say, the +
operator:
App.Model = Backbone.Model.extend({
//define constructor using a named function expression
constructor: function Model() {
Backbone.Model.prototype.constructor.apply(this, arguments);
},
//override toString to return something more meaningful
toString: function() {
return "Model(" + JSON.stringify(this.attributes) + ")";
}
});
So with:
var model = new Model({id:1,foo:"bar"})
console.log("state: " + model);
console.log(model);
You'll get:
state: Model({"id":1,"foo":"bar"})
► Model