Created
October 15, 2011 16:38
-
-
Save jpdery/1289817 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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