davimusprime
davimusprime

Reputation: 119

click event handler on dynamic tr without a child with a certain class

I've got a table that when empty/filtered w/o results throws in a tr with a td with the class "dataTables_empty". It has a message and a button that will attempt to clear the filter. I've got a jquery handler that looks like this,

$('#accountUsersTable tbody').on("click", 'tr', function (e) {
  //moves tr to another table and other magic.
}

Obviously, I don't want to move this informative tr to the other table so I tried to add a :not() to the handler but couldn't figure out how to not has child td with class dataTables_empty.

$('#accountUsersTable tbody').on("click", $('tr').filter('td').prop('class') != 'dataTables_empty', function (e) {
  //moves tr to another table and other magic.
}

Or something :/

Upvotes: 0

Views: 137

Answers (1)

Sushanth --
Sushanth --

Reputation: 55750

$('#accountUsersTable tbody').on("click", 'tr', function (e) {

   if(!$(this).find('td.dataTables_empty').length)){
      // Your logic here
   }
}

Upvotes: 1

Related Questions