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]

News Films

Our little film studio focuses on telling developer-centric stories that need to be seen.

Beyond Code: Season 3 / GopherCon 2015

 
0:00 / 0:00