I have a table which is sorted successfully using the tablesorter plugin. However, I want to highlight the text in a particular text field in a particular row. It has a unique ID, but when I place my code after the sorting code it doesn't work. Here's 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 stick an alert just after the check to see if the #new_foldername exists, I see the alert, and I see the text highlighted in the background (so my code to highlight the text works). When I click to close the alert, then the table finishes sorting... and the text is not highlighted any more.
Any ideas what might be happening?
it seems the sorting is happening asynchronously. the documentation provides a hook called 'sortEnd' where you probably want to run your highlighting code. see example from 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();
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With