Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 ?

question from:https://stackoverflow.com/questions/21625231/on-is-not-a-function-jquery-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
193 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...