+

Fix edit/del contrib btn binding

Benjamin Renard [2015-03-09 23:23:57]
Fix edit/del contrib btn binding
Filename
inc/myco.js
diff --git a/inc/myco.js b/inc/myco.js
index a898163..af7f01c 100644
--- a/inc/myco.js
+++ b/inc/myco.js
@@ -185,9 +185,6 @@ show_contributions=function(group,contributor_email,contributions) {
   _current_displayed_contributions_group=group;

   show_more_contributions();
-
-  $('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
-  $('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
 }

 show_more_contributions=function(count) {
@@ -211,7 +208,12 @@ show_more_contributions=function(count) {
 		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>";
 	  }
       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>';
-      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>');
+      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>');
+
+      tr.find('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
+      tr.find('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
+
+      tbody.append(tr);
     }
   }
 }
ViewGit