Skip to content

Instantly share code, notes, and snippets.

@jpmx
Created August 11, 2013 03:28
Show Gist options
  • Save jpmx/6203256 to your computer and use it in GitHub Desktop.
Save jpmx/6203256 to your computer and use it in GitHub Desktop.
Meteor table render bug
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
autopublish
insecure
preserve-inputs
jquery
bootstrap
/* CSS declarations go here */
table, tr, td {
border: 1px solid black;
}
.center-me {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
height: 200px;
width: 200px;
background-color: #f3f3f3;
}
<head>
<title>meteor-table-render-bug</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<h2>click a row, div missing:</h2>
<table>
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
{{#each item}}
<tr class='row-trigger'>
<td>{{this.id}}</td>
<td>{{this.name}}</td>
<td>{{this.date}}</td>
</tr>
<div class="hide center-me t1{{this.id}}">Div table1... Where i am?</div>
{{/each}}
</tbody>
</table>
<br/><br/><br/>
<h2>click a row, div there:</h2>
<table>
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
{{#each item}}
<tr class='row-trigger2'>
<td>{{this.id}}</td>
<td>{{this.name}}</td>
<td>{{this.date}} <div class="hide center-me t2{{this.id}}">Div table2</div></td>
</tr>
{{/each}}
</tbody>
</table>
</template>
if (Meteor.isClient) {
item = [
{ id: 'item1',
name: 'item 1 name',
date: new Date(),
},
{ id: 'item2',
name: 'item 2 name',
date: new Date(),
},
{ id: 'item3',
name: 'item 3 name',
date: new Date(),
},
];
Template.hello.item = function() {
return item;
}
Template.hello.events({
'click .row-trigger': function(e) {
console.log("click, showing " + '.t1'+this.id);
$('.t1'+this.id).removeClass('hide');
},
'click .row-trigger2': function(e) {
console.log("click, showing " + '.t2'+this.id);
$('.t2'+this.id).removeClass('hide');
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment