Is there a better way to create an object-oriented class with jQuery?

I quite like John Resig’s Simple JavaScript Inheritance.

var MyWidget = Class.extend({
  init: function(widget_name){
    this.widget_name = widget_name;
  },

  doSomething: function() {
    alert('my name is ' + this.widget_name);
  }
});

NB: The “Class” object demonstrated above isn’t included in jQuery itself – it’s a 25 line snippet from Mr. jQuery himself, provided in the article above.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)