Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created May 8, 2009 05:08
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 alandipert/108639 to your computer and use it in GitHub Desktop.
Save alandipert/108639 to your computer and use it in GitHub Desktop.
function tableize(wrapper, row, field, data, columns) {
return $("<"+wrapper+"/>").append(
A(data).map(function() {
var ret = $("<"+row+"/>");
$.each($.map(this, function(prop) {
for(c in columns) {
if(columns[c] == prop) {
return prop;
}
}
return null;
}, function(k,v) {
$(ret).append("<"+field+">"+v+"</"+field+">");
});
return ret;
}).get().join()
);
}
tableize("table", "tr", "td", data, new Array("title", "created"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment