Wynn Netherland changelog.com/posts

jquery.behavior: chunk up your jQuery into 'behaviors'

If you’ve written more than a trivial amount of jQuery, you quickly wonder about the best way to organize your JavaScript. @rodpetrovic’s take is called jquery.behavior:

// 1. Create behavior:
function BadBehavior(element, config) {
  this.misbehave = function () {
    alert('Oh behave!');
  }
}

// 2. Attach behavior:
$('.bad-behavior').behavior(BadBehavior);

// 3. Use behavior:
$('.bad-behavior').behavior('misbehave'); // alert('Oh behave!')

[Source on GitHub] [Homepage]


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00