Jquery 仅在初始加载时使用tablesorter addParser

Jquery 仅在初始加载时使用tablesorter addParser,jquery,tablesorter,Jquery,Tablesorter,我在我的表分类器上使用了一个解析器,我用它来设置表首次显示时的顺序。问题是,一旦显示了我的表,我希望忽略解析器,并使用默认排序选项允许用户对表进行排序。这可能吗?如果是,我该怎么做?这是我的tablesorter addParer代码:$.tablesorter.addParser({ 我不确定我是否完全理解你想要什么。但是我认为如果你想在初始化时得到一个特定的顺序,你应该用这个特定的顺序来设置HTML,而不是包含一个初始排序。 //give an id to the parser id

我在我的表分类器上使用了一个解析器,我用它来设置表首次显示时的顺序。问题是,一旦显示了我的表,我希望忽略解析器,并使用默认排序选项允许用户对表进行排序。这可能吗?如果是,我该怎么做?这是我的tablesorter addParer代码:$.tablesorter.addParser({


我不确定我是否完全理解你想要什么。但是我认为如果你想在初始化时得到一个特定的顺序,你应该用这个特定的顺序来设置HTML,而不是包含一个初始排序。
  //give an id to the parser
  id: 'campaigns',
  is: function(s) {
    return false;
  },
  format: function(s) {
    //remove any numbers and spaces in the string s
    var state = s.replace(/[0-9]/g, '').replace(/\s/g, '');
    //change inactive to a 1 and active to a 2
    //only want this to apply on load otherwise after the table has loaded
    //I don't want this to be used. I just want to ignore it
    return state.toLowerCase().replace(/inactive/,1).replace(/active/,2);
  },
  //sort on a numeric type
  type: 'numeric'
});

$(function() {
  $("table#game-data-table").tablesorter({
    //sort based off of active inactive, then off column 4,and finally off column 1
    sortList: [[1,1], [3,1], [0,0]],
    headers: {
    1: {
      sorter: 'campaigns'
    }
  }
 });
});