if (body.length == 0 && !(typeof thead === 'undefined')) {
var $tr = $(document.createElement('tr'));
var $td = $(document.createElement('td'));
- $td.attr("colspan", thead.length);
- $td.text("No data available");
- $td.addClass("empty");
+ $td.attr('colspan', thead.length);
+ $td.text('No data available');
+ $td.addClass('empty');
$tr.append($td);
$tbody.append($tr);
return $tbody;
// else, populate as usual
$(body).each(function(index, value) {
var $tr = $(document.createElement('tr'));
- // data-id
- if (value['id'] != undefined) {
- $tr.attr('data-id', value['id']);
- }
- // add classes
- $(value["type"]).each(function(index, value) {
- $tr.addClass(value);
- });
- // add entries
- $(value["entry"]).each(function(index, value) {
- var $td = $(document.createElement('td'));
- $td.append(value);
- $tr.append($td);
+ $.each(value, function(key, value) {
+ if (key == 'type') {
+ // add classes
+ $(value).each(function(index, value) {
+ $tr.addClass(value);
+ });
+ } else if (key == 'entry') {
+ // add entries
+ $(value).each(function(index, value) {
+ var $td = $(document.createElement('td'));
+ $td.append(value);
+ $tr.append($td);
+ });
+ } else {
+ // data field
+ $tr.attr('data-' + key, value);
+ }
+ $tbody.append($tr);
});
- $tbody.append($tr);
});
return $tbody;
}
one.lib.registry.alert = setTimeout(function() {
$("#alert").slideUp();
}, 8000);
-}
\ No newline at end of file
+}