Cell data returns 10x on 1 click
Cell data returns 10x on 1 click
mbelmont
Posts: 1Questions: 1Answers: 0
Can someone please tell me why this code keeps executing after one click, up to ten times, each time I click a new line?
var ztable = $('#TableId6').DataTable();
$('#TableId6 tbody').on('click', 'tr', function () {
var thisType = ztable.cell(this, 3).data();
console.log("Value of Type: ",thisType);
});
After this executes, it continues logging in the Console my Value statement 10 times, then it lags and subsequent code does not execute.
This discussion has been closed.
Answers
Copied your code into this test case and it seems to work correctly, meaning one line of output per click.
http://live.datatables.net/zokoceba/1/edit
You must have something else on your page causing the issue. 10 times is interesting. If you change the page length does it execute that number of times?
Maybe you can update the test case with more of your code to find out where the issue is.
Kevin
My guess is that the event handler is being added multiple times - but as Kevin notes, that isn't happening with the above code, so there is some information we are missing.
Allan