0

I have a private class rs. After its definition I have the following code.

rs.prototype = new EventTarget();
rs.prototype.constructor = rs;

EventTarget defines a fire method. From within an rs method I am trying to call self.fire(..) The call crashes with "undefined is not a function"

Within Chrome when I put the mouse over self it gives

__proto__: rs

opening that I have

constructor: function rs(...

under that is

prototype: EventTarget

under that is

__proto__: EventTarget

under that is

fire: function (..

How do I call the fire function? Is there a problem because this is a private class?

CarbonMan
  • 4,350
  • 12
  • 54
  • 75
  • Can you give us a fiddle so that it'll be easier to track the problem? – Mike Ante Jul 21 '14 at 08:51
  • Try to set the prototype part of inheritance with `rs.prototype = Object.create(EventTarget.prototype) ` maybe re use EventTarget constructor by rs by having `EventTarget.call(this, arguments)` in rs constructor. Constructor functions should start with an upper case so rs should be Rs. More on constructor functions and prototype here: http://stackoverflow.com/questions/16063394/prototypical-inheritance-writing-up/16063711#16063711 – HMR Jul 21 '14 at 09:06

1 Answers1

0

The problem was resolved by moving it outside the host class, so that it was no longer private. Not really a solution to the question.

CarbonMan
  • 4,350
  • 12
  • 54
  • 75