Skip to content

Commit

Permalink
make data display flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalBokBok committed Sep 16, 2015
1 parent 588ec36 commit 9e4deda
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ function deleteMember(id){
}
function renderMemberList(data){
var items = [];
// if (data.length>0){
// var keys Object.keys(val);
// }
$.each(data, function(key, val) {
items.push('<tr id="' + key + '"><td>' +
'<a href="javascript:void(0)" onclick="editMemberInitiate('+val["id"]+')">✎</a> </td><td>' +
val["name"] + '</td><td>' +
val["surname"] + '</td><td>' +
val["email_address"] + '</td><td>' +
val["street"] + '</td><td>' +
val["postal_code"] + '</td><td>' +
val["city"] + '</td><td>' +
val["country"] + '</td><td>' +
val["group"] + '</td><td>' +
val["telephone"] + '</td><td>' +
val["last_payment_year"] + '</td><td>' +
'<a href="javascript:void(0)" onclick="deleteMember('+val["id"]+')">❌</a></td></tr>');
var id = val.id;
delete val.id;
var row = '<tr><td><a href="javascript:void(0)" onclick="editMemberInitiate('+id+')">✎</a> </td>';
for (var fieldName in val) {
row += '<td>' + val[fieldName] + '</td>';
}
row += '<td><a href="javascript:void(0)" onclick="deleteMember('+id+')">❌</a></td></tr>';
items.push(row);
});
$('#memberList').replaceWith($('<table/>',{id:'memberList',html: items.join('')}));
}
Expand Down

0 comments on commit 9e4deda

Please sign in to comment.