0

I'm writing a plugin to sort a table. When someone clicks on the TH it sorts the column.

So my Jquery would be something like"

$("#TableID").AddSorting();

I'm not sure how to reference the sorting function in the Plugin. Without the plugin I'm doing the below.

 <th data-sort="LastName, FirstName">
   <a onclick="SortTheGrid("FirstName, LastName");">First Name</a>
 </th>

Maybe in the plugin I can just do:

 $this.find("th[data-sort] a").click(function(){...});

thanks Chuck

user965445
  • 115
  • 1
  • 10

1 Answers1

0

Just use jQuery's click functionality.

e.g.,

function doSort () {
    //your sort code here
}

$(document).ready(function () {
    $("#YourButtonName").click(function () { doSort(); });
});

You still need to pass arguments into your click handler, so it knows which columns to sort by. There's details of how to pass parameters to a jQuery click event handler in this answer.

Community
  • 1
  • 1
Deleted
  • 900
  • 5
  • 9