Skip to content

Instantly share code, notes, and snippets.

@iptpv
Created November 11, 2016 15:57
Show Gist options
  • Save iptpv/d87e8494d5c793d520df966793291541 to your computer and use it in GitHub Desktop.
Save iptpv/d87e8494d5c793d520df966793291541 to your computer and use it in GitHub Desktop.
component idea, booking com inspired
var L = {
};
L.alert = function() {
console.log($(this).html()+1);
};
L.cons = function() {
console.log($(this).html());
};
$.fn.loadComponents = function() {
$(this).filter('[data-c]').each(L[$(this).data('c')]);
};
$('[data-c="cons"]').loadComponents();
$('<div data-c="alert">o0</div><div data-c="cons">o07</div>').appendTo('body').loadComponents();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment