1.0.1 • Published 3 years ago

jquery-behaviours v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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.