Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 }) 

This is an image of the error

like image 545
TaGiang Avatar asked Aug 26 '15 15:08

TaGiang


2 Answers

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

like image 199
smoksnes Avatar answered Sep 25 '22 06:09

smoksnes


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 () {}); 
like image 37
Edwin Mendez Avatar answered Sep 22 '22 06:09

Edwin Mendez