Fix edit/del contrib btn binding
Benjamin Renard

Benjamin Renard commited on 2015-03-09 23:23:57
Showing 1 changed files, with 6 additions and 4 deletions.

... ...
@@ -185,9 +185,6 @@ show_contributions=function(group,contributor_email,contributions) {
185 185
   _current_displayed_contributions_group=group;
186 186
 
187 187
   show_more_contributions();
188
-  
189
-  $('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
190
-  $('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
191 188
 }
192 189
 
193 190
 show_more_contributions=function(count) {
... ...
@@ -211,7 +208,12 @@ show_more_contributions=function(count) {
211 208
 		cat='<br/><span class="category"><span class="cat-color" style="background-color: '+_current_displayed_contributions_group.categories[_current_displayed_contributions[idx].category]['color']+'"></span> '+_current_displayed_contributions_group.categories[_current_displayed_contributions[idx].category]['name']+"</span>";
212 209
 	  }
213 210
       col_actions='<td><div class="btn-group" data-uuid="'+_current_displayed_contributions[idx].uuid+'"><button type="button" class="btn btn-default btn-sm contribution_edit_btn"><span class="glyphicon glyphicon-edit"></span></button><button type="button" class="btn btn-default btn-sm contribution_delete_btn"><span class="glyphicon glyphicon-trash"></span></button></div></td>';
214
-      tbody.append('<tr><td>'+_current_displayed_contributions[idx].getTitle()+cat+'</td><td>'+_current_displayed_contributions[idx].cost.toFixed(2)+' €<br/><span class="date">'+moment(_current_displayed_contributions[idx].date).format('DD/MM/YYYY')+'</span></td>'+col_actions+'</tr>');
211
+      var tr=$('<tr><td>'+_current_displayed_contributions[idx].getTitle()+cat+'</td><td>'+_current_displayed_contributions[idx].cost.toFixed(2)+' €<br/><span class="date">'+moment(_current_displayed_contributions[idx].date).format('DD/MM/YYYY')+'</span></td>'+col_actions+'</tr>');
212
+
213
+      tr.find('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
214
+      tr.find('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
215
+
216
+      tbody.append(tr);
215 217
     }
216 218
   } 
217 219
 }
218 220