Uncaught TypeError: ((x.event.special[i.origType] || (intermediate value)).handle || i.handler).apply is not a function
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 })
Solution 1:
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
Solution 2:
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 () {});
Solution 3:
In my case I had typed
$('body').click('click','.delete_item',function(e){})
When I had meant to type:
$('body').on('click','.delete_item',function(e){})
changing that click
to on
removed the error.