Skip to content

Commit 9bf5f38

Browse files
committed
fixed account counting/event handlers
1 parent b8ed337 commit 9bf5f38

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

static/js/account.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,26 @@ function addAdmin(admin) {
2121

2222
row.append('<th class="col-md-1 col-lg-1 col-xl-1 row-number" scope=row>0</th>');
2323
row.append('<td class="col-md-10 col-lg-10 col-xl-10">' + admin.Handle + '</td>');
24-
row.append('<td class="col-md-1 col-lg-1 col-xl-1">' + makeDeleteButton() + '</td>');
24+
var deleteButton = $(makeDeleteButton());
25+
var deleteColumn = $('<td class="col-md-1 col-lg-1 col-xl-1"></td>');
26+
deleteColumn.append(deleteButton);
27+
row.append(deleteColumn);
2528

2629
var wrapper = $('#admin-list-wrapper');
2730
if (wrapper.is(':hidden')) {
2831
$('#admin-selection-table > tbody').append(row);
2932

3033
recountAdmins();
31-
addDeleteAdminListener();
32-
3334
wrapper.show('slow');
3435
$('#admin-list-header').show('slow');
3536
} else {
3637
row.hide();
3738
row.appendTo('#admin-selection-table > tbody').show('fast');
3839

3940
recountAdmins();
40-
addDeleteAdminListener();
4141
}
42+
43+
addDeleteHandler($(deleteButton.find('.delete-button')));
4244
};
4345

4446
function addHandleChangeListener() {
@@ -164,7 +166,11 @@ function addPasswordChangeListener() {
164166
};
165167

166168
function addDeleteAdminListener() {
167-
$('.delete-button').click(function(event) {
169+
addDeleteHandler($('.delete-button'));
170+
};
171+
172+
function addDeleteHandler(object) {
173+
object.click(function(event) {
168174
event.stopPropagation();
169175
event.preventDefault();
170176

@@ -186,11 +192,13 @@ function addDeleteAdminListener() {
186192
if (count <= 1) {
187193
$('#admin-list-header').hide('400');
188194
$('#admin-list-wrapper').hide('400', function() {
189-
row.remove();
195+
row.remove();
196+
recountAdmins();
190197
});
191198
} else {
192199
row.hide('fast', function() {
193-
this.remove();
200+
this.remove();
201+
recountAdmins();
194202
});
195203
}
196204
}).fail(alertAjaxFailure);

static/js/networks.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ function addEncoder(encoder) {
260260
'</td>');
261261

262262
var disconnectItem = $('<td class="encoder-connect-row">' + makeDisconnectButton() + '</td>');
263-
264263
var count = body.children().length;
265-
266264
var row = $('<tr class="encoder-row" data-encoder-id="' + encoder.ID + '"></tr>');
267265

268266
row.append('<th class="row-number" scope=row>' + (count + 1) + '</th>');

0 commit comments

Comments
 (0)