I am trying to use this
when invoking a constructor function. I am passing an object literal into the constructor as an argument.
var testView = new View({
element: '.testEl',
model: player,
initialize: function() {
var self = this;
setTimeout(function() {
self.model.set({
name: 'Billy'
});
}, 5000);
}
}); // view instance
But when I log this
inside the object it just gives me View {}
but none of the methods inside.
I want to access the model
, obviously I am lacking some knowledge here and I am asking why does this
not work as expected in the example above?
The view looks like
// View
var View = function(object) {
object.initialize.call(this);
this.element = document.querySelector(object.element);
this.element.innerHTML = object.model.get('name');
setTimeout(function() {
this.element.innerHTML = object.model.get('name');
}, 6000);
};