I seem to have a very difficult situation. I would like to pass an instance of the object to the event listener of the DOM element that was created by the same instance of the object (if that makes sense).
function Object(callback){
this.callback = callback;
this.node = document.createElement('div');
this.send = function(){
document.getElementById('list').appendChild(this.node);
}
this.node.addEventListener('click',function(){},true);
}
I know that use callback()will work inside the event listener, but this is not what I need, because I will use variables from the instance that are not later passed from the construct.
How can i solve this?
source
share