I encountered a similar issue and the solution was to switch from an arrow function to a traditional named function. Sometimes old is gold but I'm sure there is a root cause somewhere.
This didn't work:
$(document).ready(() => {
$('#client_id').change(() => {
const clientId = $(this).val();
console.log(clientId);
});
});
The console print out was the error:
TypeError: i.nodeName is undefined
On further investigation it turned out '$(this)' was calling the window object rather than the select element. (As pointed out by Rory above: https://mcmap.net/q/1251144/-a-nodename-is-undefined-jquery-error)
This worked. A value was printed out to the console.
$(document).ready(() => {
$('#client_id').change(function changeClient() {
const clientId = $(this).val();
console.log(clientId);
});
});
UPDATE
This is one of the limitations of arrow functions. And I quote, "Does not have its own bindings to this or super, and should not be used as methods." Since the jQuery method above uses 'this' context, arrow functions should be avoided in such a case and a traditional function expression used instead. Here's the documentation to support this.
deleteThisRow
,this
will refer towindow
, not the image. Why don't you bind the event handler with jQuery? – Degreeday