Please help me. This is an error when I use jQuery
in ASP.NET MVC.
Uncaught TypeError: ((x.event.special[i.origType] || (intermediate value)).handle || i.handler).apply is not a function Uncaught TypeError: ((x.event.special[i.origType] || (intermediate value)).handle || i.handler).apply is not a function
The code that causes this is:
$('#btnClick').click(function(){ //code })
In my case the error was caused by binding events to functions that didn't exist. I had removed functions that I didn't know was bound to events.
See snippet below:
var foo = { bar1: function(){ alert('working'); } }; // Working $('body').on('click', '.my-button', foo.bar1); // Not Working because bar2 doesn't exist $('body').on('click', '.my-button', foo.bar2);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <span class="my-button">Click me</span>
It will produce:
Uncaught TypeError: ((n.event.special[g.origType] || (intermediate value)).handle || g.handler).apply is not a function
If this is helpful to anyone this can be also because an event handler function is declared twice.
A coworker of mine coded the event as 'on' twice and I solved (Fool challenge by the way).
For example if you have a typing mistake:
$(document).on('change', '#selectInput').on('change', '#selectInput', function () {});
Must be:
$(document).off('change', '#selectInput').on('change', '#selectInput', function () {});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With