[frio] Replace only the users table element when reordering on a column in mod_admin.js
- Replace duplicate jQuery query with a variable
This commit is contained in:
parent
9b85d0b16e
commit
dcd7553da9
1 changed files with 8 additions and 7 deletions
|
@ -2,16 +2,17 @@
|
||||||
* Javascript for the admin module
|
* Javascript for the admin module
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(function() {
|
||||||
$('body').on('click', '.selectall', function() {
|
let $body = $('body');
|
||||||
|
$body.on('click', '.selectall', function() {
|
||||||
selectall($(this).data('selectAll'));
|
selectall($(this).data('selectAll'));
|
||||||
});
|
});
|
||||||
$('body').on('click', '.selectnone', function() {
|
$body.on('click', '.selectnone', function() {
|
||||||
selectnone($(this).data('selectNone'));
|
selectnone($(this).data('selectNone'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Toggle checkbox status to all or none for all checkboxes of a specific
|
// Toggle checkbox status to all or none for all checkboxes of a specific
|
||||||
// css class.
|
// css class.
|
||||||
$('body').on('change', 'input[type=checkbox].selecttoggle', function() {
|
$body.on('change', 'input[type=checkbox].selecttoggle', function() {
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
if ($this.prop('checked')) {
|
if ($this.prop('checked')) {
|
||||||
selectall($this.data('selectClass'));
|
selectall($this.data('selectClass'));
|
||||||
|
@ -23,7 +24,7 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Use AJAX calls to reorder the table (so we don't need to reload the page).
|
// Use AJAX calls to reorder the table (so we don't need to reload the page).
|
||||||
$('body').on('click', '.table-order', function(e) {
|
$body.on('click', '.table-order', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Get the parent table element.
|
// Get the parent table element.
|
||||||
|
@ -31,15 +32,15 @@ $(function() {
|
||||||
var orderUrl = this.getAttribute("data-order-url");
|
var orderUrl = this.getAttribute("data-order-url");
|
||||||
table.fadeTo("fast", 0.33);
|
table.fadeTo("fast", 0.33);
|
||||||
|
|
||||||
$("body").css("cursor", "wait");
|
$body.css("cursor", "wait");
|
||||||
|
|
||||||
$.get(orderUrl, function(data) {
|
$.get(orderUrl, function(data) {
|
||||||
// Find the table element in the html we got.
|
// Find the table element in the html we got.
|
||||||
var result = $(data).find('#' + table[0].id);
|
var result = $(data).find('#' + table[0].id);
|
||||||
// And add the new table html to the parent.
|
// And add the new table html to the parent.
|
||||||
$(table).parent().html(result);
|
$(table).replaceWith(result);
|
||||||
|
|
||||||
$("body").css("cursor", "auto");
|
$body.css("cursor", "auto");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue