A question about John Resig's Simple Javascript Inheritance.

Posted by Zippo on Stack Overflow See other posts from Stack Overflow or by Zippo
Published on 2010-05-26T18:58:56Z Indexed on 2010/05/26 19:01 UTC
Read the original article Hit count: 406

Filed under:
|

I'm using this simple code: http://ejohn.org/blog/simple-javascript-inheritance/
Using this "library", I made this simple class:

var Person = Class.extend({
  init: function(openningSentence) {
    this.say(openningSentence);
  },

  say: function(words) {
    alert(words);
  }
});

The problem with this class, is that I can't call a function using the variable "this" (line 3 in the code gives an error: unknown method "say").

Does anybody knoes if there's a solution for this problem?
Btw - I'm using jquery, so if there's a jquery-based solution It'll be great :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery