I am trying to import jquery into my prototyped class which works initially in the constructor.
I lose my scope of jquery in the call to resizeCanvas event. It says the width() and height() function is undefined.
Is there a way I won't lose the jquery variable.
define(['jquery'], function($) {
function Canvas() {
this.canvas = document.getElementById('canvas');
this.context = this.canvas.getContext('2d');
this.rowbuild = $('#rowbuild');
}
Canvas.prototype.addResizeListener = function() {
window.addEventListener('resize', this.resizeCanvas, false);
};
Canvas.prototype.resizeCanvas = function() {
this.canvas.width = this.rowbuild.width();
this.canvas.height = this.rowbuild.height();
};
return Canvas;
});