jquery-behaviours
v1.0.1
Published
JQuery behaviour registry plugin
Downloads
2
Readme
jquery-behaviours
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.