mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Parser: update input/select elements binding
This commit is contained in:
parent
24d1865df4
commit
98d47ff3bb
@ -68,13 +68,13 @@
|
|||||||
// This method only works with jQuery 1.7+
|
// This method only works with jQuery 1.7+
|
||||||
// you can change it to use delegate (v1.4.3+) or live (v1.3+) as desired
|
// you can change it to use delegate (v1.4.3+) or live (v1.3+) as desired
|
||||||
// if this code interferes somehow, target the specific table $('#mytable'), instead of $('table')
|
// if this code interferes somehow, target the specific table $('#mytable'), instead of $('table')
|
||||||
$(window).load(function(){
|
$(function(){
|
||||||
|
$('table').on('tablesorter-initialized', function(){
|
||||||
// this flag prevents the updateCell event from being spammed
|
// this flag prevents the updateCell event from being spammed
|
||||||
// it happens when you modify input text and hit enter
|
// it happens when you modify input text and hit enter
|
||||||
var alreadyUpdating = false,
|
var alreadyUpdating = false;
|
||||||
t = $.tablesorter.css.table || 'tablesorter';
|
|
||||||
// bind to .tablesorter (default class name)
|
// bind to .tablesorter (default class name)
|
||||||
$('.' + t).find('tbody').on('change', 'select, input', function(e){
|
$(this).children('tbody').on('change', 'select, input', function(e){
|
||||||
if (!alreadyUpdating) {
|
if (!alreadyUpdating) {
|
||||||
var $tar = $(e.target),
|
var $tar = $(e.target),
|
||||||
$cell = $tar.closest('td'),
|
$cell = $tar.closest('td'),
|
||||||
@ -88,11 +88,13 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
alreadyUpdating = true;
|
alreadyUpdating = true;
|
||||||
$table.trigger('updateCell', [ $tar.closest('td'), resort ]);
|
$table.trigger('updateCell', [ $tar.closest('td'), resort, function(){
|
||||||
updateServer(e, $table, $tar);
|
updateServer(e, $table, $tar);
|
||||||
setTimeout(function(){ alreadyUpdating = false; }, 10);
|
setTimeout(function(){ alreadyUpdating = false; }, 10);
|
||||||
|
} ]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
Reference in New Issue
Block a user