Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$(...).on is not a function - jQuery Error

I am using dialog box, which I am closing when a user click anywhere on page expect that dialog box.

Here is my code:

$('body').on('click','.ui-widget-overlay',function() {      $('#myRateSettingsPopup').dialog('close');  });  

Somehow its returning an error:

$(...).on is not a function

What is wrong with my code ?

I am using jquery-1.6.1.min.js , but I cannot update it to the latest version. I am bound.

Is there any other way to do this ?

like image 599
Hassan Sardar Avatar asked Feb 07 '14 10:02

Hassan Sardar


People also ask

How do I fix error not function?

The TypeError: "x" is not a function can be fixed using the following suggestions: Paying attention to detail in code and minimizing typos. Importing the correct and relevant script libraries used in code. Making sure the called property of an object is actually a function.

Is not a function TypeError is not a function?

This is a standard JavaScript error when trying to call a function before it is defined. This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the expression did not return a function object.

Is not defined in jQuery?

You may experience the “jQuery is not defined error” when jQuery is included but not loaded. Make sure that it's loaded by finding the script source and pasting the URL in a new browser or tab. The snippet of text you should look for to find the URL to test.

Is not a function in JavaScript?

The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function.


1 Answers

Method on was introduced in jQuery version 1.7.

I think you have to upgrade your jQuery library to the newest version.

Otherwise, you can use bind:

$( ".ui-widget-overlay" ).bind( "click", function(e) {     $('#myRateSettingsPopup').dialog('close');     e.stopPropagation();  }); 
like image 76
Anirudha Gupta Avatar answered Sep 30 '22 14:09

Anirudha Gupta