Normally im using this keyword in Jquery to refer to an element, but in my current code it is not behaving as expected.
This is my code (the relevant part)
$("#myTable tbody").on('sortstart', 'tr', function(event, ui) {
$(this).children("td").css({'background-color': '#313131'});
});
I would expect this to mean tr in this case, but it doesnt. What does it refer to?
the whole thing, if anyone wants to have a look:
It does refer to the
tr, but the problem is that the eventsortstartnever triggers. Try changing the event to for exampleclickand it works just fine.The
sortstartevent doesn’t get triggered because you’re binding the handler to thetrchildren, not to thetbodythat has been initialized as sortable. A sortable object’s children don’t trigger the event.