Skip to content

Latest commit

 

History

History
40 lines (33 loc) · 835 Bytes

README.md

File metadata and controls

40 lines (33 loc) · 835 Bytes

jquery-behaviours

Build Status

Simple jQuery plugin for behaviour attaching. For when you don't have anything like the need for a full-blown front-end framework à la Angular or React.

// register
$.fn.behaviours.register('.selector', function() {
  $(this).click(function() {
    // blah
  });
});
// on page load
$(function() {
  $(document).behaviours();
});
// reapply on DOM change
$(function() {
  $('.selector').load('/fragment.html').complete(function() {
    $(this).behaviours();
  });
});
// to hell with <script> tag order
$.fn.behaviours.register('.selector', function() {
  // blah
}, $.fn.behaviours.MAX_PRIORITY);

etc.