I tried this:
$('body').on('click', '.headerCheckbox', function (event) { // Add event here and magic should happen?
event.stopPropagation(); // event output in firebug: event: [object Object]
headerCheckboxClicked($(this));
});
It's a table, where I have a checkbox in a header in one of the columns. I want to stop event bubbling so the table doesn't get the event so it doesn't sorts the column.
I thought this was the right way but the table stills sorts after I added the line. I can't find a good example to work with in the jQuery Documentation.
Alternative solution The datatable way I disable sorting on the specify column.
table3 = $("#tableComputerPackages").DataTable({
"order": [[1, "desc"]],
"columnDefs":
[
{
"targets": 0,
"orderable": false
}
]
});
A. Wolff had the answer to the question thought. It was because I wrote the on() with the 3 parameters version instead of 2 which I am use to, so I didn't even think about it.
function(event)..$('.headerCheckbox').on('click', function (event) {event.stopPropagation(); //...});