Skip to content

Instantly share code, notes, and snippets.

@skyzyx
Created January 9, 2010 18:43
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 skyzyx/273034 to your computer and use it in GitHub Desktop.
Save skyzyx/273034 to your computer and use it in GitHub Desktop.
(function() {
// Declare variables, and provide data to generate a table with.
var cols = ['col-1', 'col-2', 'col-3', 'col-4', 'col-5'],
cells = _.splitBy(['cell-1', 'cell-2', 'cell-3', 'cell-4', 'cell-5', 'cell-6', 'cell-7', 'cell-8', 'cell-9', 'cell-10', 'cell-11', 'cell-12'], cols.length);
var __ = DOMBuilder;
document.getElementById('demo03').appendChild(__.DOM([
__('p').html('A table, generated programmatically with nested anonymous callbacks, from data.'),
__('table', { 'width':'20%', 'border':'1' }).child([
__('thead').child(
__('tr').child(_.map(cols, function(c) {
return __('th').html(c);
}))
),
__('tbody').child(_.map(cells, function(tr) {
return __('tr').child(_.map(tr, function(td) {
return __('td').html(td);
}));
}))
])
]));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment