Uncaught TypeError: jQuery(...).on is not a function | Community
Skip to main content
Roshanchauhan
Level 3
Jul 26, 2018 9:12 AM UTC
Solved

Uncaught TypeError: jQuery(...).on is not a function

Hi,

Getting "Uncaught TypeError: jQuery(...).on is not a function" error while testing the custom tracking and this is happening only on one page rest it's working fine, as we can see in the below screenshot.

Error line:

Function:

function bindKudoEvent(){
jQuery('.lia-button-image-kudos-kudoed a.kudos-link').on('click',function(e){
var isAcceptedSol = jQuery(this).parents('.lia-message-view-display').hasClass('lia-accepted-solution');
trackClickTkb(0,"kudo count",isAcceptedSol)
setTimeout(function(){ bindKudoEvent() }, 3500);
});
jQuery('.lia-button-image-kudos-not-kudoed a.kudos-link').on('click',function(e){
var isAcceptedSol = jQuery(this).parents('.lia-message-view-display').hasClass('lia-accepted-solution');
trackClickTkb(1,"kudo count", isAcceptedSol)
setTimeout(function(){ bindKudoEvent() }, 3500);
});
}

bindKudoEvent();

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Stewart_Schilling
Stewart_SchillingAccepted solution
New Participant
Aug 16, 2018 5:20 PM UTC

If jQuery is loading asynchronously you could have a race condition between DTM and the loading of jQuery.

I don't think that you need to do event handling this way.  I'd use event rules within DTM.  That would free you from this issue.

In cases where I do need to work outside of DTM, I try to use native Javascript to avoid dependencies on libraries like jQuery.

3 replies

Stewart_Schilling
Stewart_SchillingAccepted solution
New Participant
Aug 16, 2018 5:20 PM UTC

If jQuery is loading asynchronously you could have a race condition between DTM and the loading of jQuery.

I don't think that you need to do event handling this way.  I'd use event rules within DTM.  That would free you from this issue.

In cases where I do need to work outside of DTM, I try to use native Javascript to avoid dependencies on libraries like jQuery.

Translate
Roshanchauhan
Level 3
Aug 7, 2018 7:17 AM UTC

jQuery exist on the page I got this error on page load mostly.

Translate
New Participant
Jul 26, 2018 6:16 PM UTC

Does jQuery exist on the page at the point that your function is executed? If not, then that would cause this error.

Translate