我有一個視圖模型是這樣的:從事件偵聽器對象調用函數
CANVAS = getElementById...
RemixView = function(attrs) {
this.model = attrs.model;
this.dragging = false;
this.init();
};
RemixView.prototype = {
init: function() {
CANVAS.addEventListener("click", this.handleClick);
},
handleClick: function(ev) {
var obj = this.getHoveredObject(ev);
},
getHoveredObject: function(ev) {}
...
...
}
rv = new RemixView()
問題是我當clickHandler事件觸發的事件,此對象等於CANVAS對象,不RemixView。所以我得到的錯誤說:
this.getHoveredObject is not a function
什麼是正確的方法在那stutry?
它的工作表示感謝! –