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,30 +68,32 @@
|
|||||||
// 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(){
|
||||||
// this flag prevents the updateCell event from being spammed
|
$('table').on('tablesorter-initialized', function(){
|
||||||
// it happens when you modify input text and hit enter
|
// this flag prevents the updateCell event from being spammed
|
||||||
var alreadyUpdating = false,
|
// it happens when you modify input text and hit enter
|
||||||
t = $.tablesorter.css.table || 'tablesorter';
|
var alreadyUpdating = false;
|
||||||
// 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'),
|
||||||
$table = $cell.closest('table'),
|
$table = $cell.closest('table'),
|
||||||
indx = $cell[0].cellIndex,
|
indx = $cell[0].cellIndex,
|
||||||
c = $table[0].config || false,
|
c = $table[0].config || false,
|
||||||
$hdr = c && c.$headers && c.$headers.eq(indx);
|
$hdr = c && c.$headers && c.$headers.eq(indx);
|
||||||
// abort if not a tablesorter table, or
|
// abort if not a tablesorter table, or
|
||||||
// don't use updateCell if column is set to "sorter-false" and "filter-false", or column is set to "parser-false"
|
// don't use updateCell if column is set to "sorter-false" and "filter-false", or column is set to "parser-false"
|
||||||
if ( !c || ( $hdr && $hdr.length && ( $hdr.hasClass('parser-false') || ($hdr.hasClass('sorter-false') && $hdr.hasClass('filter-false')) ) ) ){
|
if ( !c || ( $hdr && $hdr.length && ( $hdr.hasClass('parser-false') || ($hdr.hasClass('sorter-false') && $hdr.hasClass('filter-false')) ) ) ){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
alreadyUpdating = true;
|
||||||
|
$table.trigger('updateCell', [ $tar.closest('td'), resort, function(){
|
||||||
|
updateServer(e, $table, $tar);
|
||||||
|
setTimeout(function(){ alreadyUpdating = false; }, 10);
|
||||||
|
} ]);
|
||||||
}
|
}
|
||||||
alreadyUpdating = true;
|
});
|
||||||
$table.trigger('updateCell', [ $tar.closest('td'), resort ]);
|
|
||||||
updateServer(e, $table, $tar);
|
|
||||||
setTimeout(function(){ alreadyUpdating = false; }, 10);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user