I found some odd behavior that I wanted to get some feedback on. Being a javaScript novice, it is probably just me.
I have a table where I have javaScript do something if a checkbox is checked. This is working great.
//on change of the table run function $('#q119').on('click', 'input[type="checkbox"]', bothFunctions);
In the same table, there is a column with a dropdown. On a change to the dropdown a function runs:
$('#q119 select').on('change', bothFunctions);
This works great unless the add row link is clicked. Any new row ignores the above 'on change of select' code.
I tested this by changing the code to the following:
$('tr').on('mouseover', function(){ console.log('if over a row'); }); $('td').on('mouseover', function(){ console.log('if over a column'); });
The console log would have a result UNLESS the mouse hovered over the new 'added new row'.
I backed the code up to test with tbody and it was successful:
$('tbody').on('mouseover', function(){ console.log('if over a table'); });
There is a cutoff between tbody and trow.
My final code, which is working well:
$('#q119 tbody').on('change', function(){ bothFunctions(); });
Can anyone tell me why this is happening? The row is clearly in the code of the table:
Thanks for the input. This has been puzzling me quite a bit. Thanks!