09 Jul

Binding just got easier

When coding in mootools, a lot of function binding goes on in my case. In fact, pretty much every time I call a class method I want it bound to the class. Jan Kassens comes to the rescue with a simple method which enables your class functions to be bound upon initialization. If you find yourself using .bind(this) a lot, this could make your code much prettier.

To make this work, you simply add this into your javascript (you could even add it to your MooTools file, as I bet and hope this becomes integrated into a future release) and use the property Bind in your class the same way you use Implements and Extends. Check out his blog article for a great explanation.

If you liked this post, why not share it?

  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Reddit
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter

Related Posts

blog comments powered by Disqus