Skip to content

Instantly share code, notes, and snippets.

@jpdery
Created October 15, 2011 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpdery/1289817 to your computer and use it in GitHub Desktop.
Save jpdery/1289817 to your computer and use it in GitHub Desktop.
var List = new Class({
Roles: {
'list-item': function(element) {
element.addClass('ui-list-item');
}
},
initialize: function(element) {
element.getElements('[data-role]').each(function(el) {
var role = el.get('data-role');
if (this.Roles[role]) {
this.Roles[role].apply(this, [el]);
}
});
}
});
var element = new Element('ul').adopt([
new Element('li[data-role=list-item]', {'text': 'Item 1'}),
new Element('li[data-role=list-item]', {'text': 'Item 2'}),
new Element('li[data-role=list-item]', {'text': 'Item 3'})
]);
var myList = new List(element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment