Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25944

event listener, objects and this

From pentapus <pentapus@example.com>
Newsgroups comp.lang.javascript
Subject event listener, objects and this
Date 2014-10-20 21:33 -0400
Organization albasani.net
Message-ID <m24d5j$b2h$1@news.albasani.net> (permalink)

Show all headers | View raw


I'm writing an object for an HTML5 audio player

in my object initialization code I have this:

function audioVideoPlayer(id){
	this.id = id;
	this.playing = false;
	this.endOfTrack =  endOfTrack;
...

	this.player.addEventListener("ended",this.endOfTrack);

That calls the endOfTrack function but the endOfTrack function believes 
"this" refers to the audio element, not to the object I wrote. How do I 
properly call the endOfTrack method?

Nice to see this group is still kicking and doing good work.


-- 
pentapus

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

event listener, objects and this pentapus <pentapus@example.com> - 2014-10-20 21:33 -0400
  Re: event listener, objects and this JJ <jj4public@vfemail.net> - 2014-10-21 13:41 +0700

csiph-web