'$(this).prop('id') is undefined in a named event handler
In my TypeScript named event handler that handles both onload and onchange events of an element GG0170I. For some reason the thisGG0170I.prop('id') is undefined inside the named handler function checkGG0170I(e){}.
const branchingController = (function() {
function GG0170JKLMN_depends_on_GG0170I(loadEventData: EnumChangeEventArg): void {
const GG0170I = $('.persistable[id^=GG0170I');
function checkGG0170I(e) {
const thisGG0170I = $(this);
/**** problem: thisGG0170I.prop('id') is undefined *****/
if (thisGG0170I.prop('id').indexOf('Admission_Performance') !== -1) {
}
}
/* on change */
GG0170I.each(function() {
const thisI = $(this);
thisI.on('change', {
x: EnumChangeEventArg.Change
}, checkGG0170I);
})
/* on load */
checkGG0170I(loadEventData);
}
function LoadAllRules(loadEventData: EnumChangeEventArg): void {
GG0170JKLMN_depends_on_GG0170I(loadEventData);
GG0170P_depends_on_GG0170M_and_GG0170N(loadEventData);
GG0170Q_is_No_skip_to_Complete(loadEventData);
}
return {
'LoadAllRules': LoadAllRules,
'GG0170JKLMN_depends_on_GG0170I': GG0170JKLMN_depends_on_GG0170I,
'GG0170P_depends_on_GG0170M_and_GG0170N': GG0170P_depends_on_GG0170M_and_GG0170N,
}
})();
$(function(e) {
branchingController.LoadAllRules(EnumChangeEventArg.Load);
});
Solution 1:[1]
You have error here :
const GG0170I = $('.persistable[id^=GG0170I');
correction
const GG0170I = $('.persistable[id^=GG0170I]');
i hope it was useful
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Joukhar |
