Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of the script.aculo.us user interface JavaScript library, a member of the Prototype core team and a Ruby on Rails core alumnus. You're using my work every day, even if you're not aware of it (sounds creepy, I know!). Need JS foo? Hire me.

JavaScript decorator pattern

August 25th, 2006 by Thomas Fuchs, Comments Off

Decorator pattern in JavaScript? Sure can do. Read the article on how to augment arbitrary JavaScript objects with custom before and after events.

Basically, it boils down to this:


actsAsDecorator(Ajax.InPlaceEditor.prototype);
Ajax.InPlaceEditor.prototype.after(
  'enterEditMode', function() {
    // do something
  }
);

Nicely done, and very useful to add your own tweaks to existing JavaScript controls and components.

Post to Twitter Tweet This Post Post to Digg Digg This Post Post to Facebook Share on Facebook

Comments Off

JavaScript Rocks! Peformance ebook
Do you run a web site or web application? Do your users a favor, and grab our ebook on JavaScript performance. Profit from our knowledge gathered in over 15 years of working with the Web and JavaScript and make your sites ultra-fast and your users ultra-happy.

Comments are closed.