JQuery tablesorter plugin - do AFTER table sorting

I have a table that is sorted successfully using the tablesorter plugin. However, I want to highlight the text in a specific text box on a specific line. It has a unique identifier, but when I post my code after the sort code, it does not work. Here is my code:

jQuery(document).ready(function() { 
  jQuery("#filetable").tablesorter({
    sortList: [[3,1]],
    widgets: ['zebra'],
    testExtraction: "complex"
  });
  //my new code which doesn't work as expected
  if(jQuery("#new_foldername").length > 0){ 
    jQuery("#new_foldername").focus(function() { jQuery(this).select(); } ); 
  }
}); 

If I inserted a warning immediately after checking to see if #new_foldername exists, I see a warning and I see text highlighted in the background (so my code to highlight the text works). When I click to close the warning, the table finishes sorting ... and the text no longer stands out.

Any ideas what could happen?

+3
4

, . "sortEnd", , , . . http://tablesorter.com/docs/example-triggers.html

$(document).ready(function() { 
    // call the tablesorter plugin, the magic happens in the markup 
    $("table").tablesorter(); 

    //assign the sortStart event 
    $("table").bind("sortStart",function() { 
        $("#overlay").show(); 
        }).bind("sortEnd",function() { 
        $("#overlay").hide(); 
    }); 
}); 
+5

, ,

, sortEnd . ...

:

jQuery.tablesorter.addWidget({ 
  id: "highlightNewFolder", 
  // format is called when the on init and when a sorting has finished 
  format: function(table) { 
    if(jQuery("#new_foldername").length > 0){  
      jQuery("#new_foldername").focus();
    }
  } 
});

. , / . - , "select()" , :

jQuery("#new_foldername").focus(function() { jQuery(this).select(); } ); 

- , , !

0

You can use the initializedcallback function (or bind to an tablesorter-initializedevent ) ( source ) Note: those only work on the Mottie fork tablesorter , not the original (v2.0.5).

jQuery(document).ready(function() {
    jQuery("#filetable").tablesorter({
        sortList: [[3, 1]],
        widgets: ['zebra'],
        testExtraction: "complex",
        initialized: function() {
            if (jQuery("#new_foldername").length > 0) {
                jQuery("#new_foldername").focus(function() {
                    jQuery(this).select();
                });
            }
        }
    });
});
0
source

Maybe something has changed. The answers do not work for me, but it works:

$("#filetable").tablesorter().bind("sortEnd", function (e, t) {
    customHilite();
});

Zebra plugin does not work for me. maybe due to the way I filtered the rows.

0
source

Source: https://habr.com/ru/post/1755789/


All Articles