この質問は以前に尋ねられたかもしれませんが、ページの読み込み時にデータテーブルをソートできる位置に固執しています.しかし、テーブル全体をajaxによって入力されたデータに置き換えると、動作が停止します.助けてください. .
jQueryテーブルソートに従って次のコードを使用しています
$('#loc_sort, #rate_sort') // these are the th ids that i want to sort
.wrapInner('<span title="sort this column"/>')
.each(function(){
var th = $(this),
thIndex = th.index(),
inverse = false;
th.click(function(){
table.find('td').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
return $.text([a]) > $.text([b]) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
// parentNode is the element we want to move
return this.parentNode;
});
inverse = !inverse;
});
});
このコードを .on メソッドで使用する方法を教えてください。ajax からの html コードを追加します
<div id="outer_all_div"></div>
div.これは置き換えられません.私を助けてください.よろしくお願いします.