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

后端 未结 5 721
旧巷少年郎
旧巷少年郎 2020-12-15 15:34

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-         


        
相关标签:
5条回答
  • 2020-12-15 16:06

    As jquery 1.6.1 is not supporting on so you can use live

    $('body').live('click','.ui-widget-overlay',function(event)
    { 
              event.stopPropagation();        
              $('#myRateSettingsPopup').dialog('close'); 
    
    });
    
    0 讨论(0)
  • 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(); 
    });
    
    0 讨论(0)
  • 2020-12-15 16:09

    The replacement for .on() in jQuery > 1.4.2 is delegate()

    $('body').delegate('.ui-widget-overlay', 'click', function () {
        $('#myRateSettingsPopup').dialog('close');
    });
    
    0 讨论(0)
  • 2020-12-15 16:22
    $( ".close" ).bind( "click", function(e) {
    $('#popup1').hide();
        e.stopPropagation(); 
    });
    

    jquery-1.7 jqueryui/1.8.2 perfect.

    or your overlay

    $( ".YOUR OVERLAY" ).bind( "click", function(e) {
    $('#YOUR POPUP').hide();
       e.stopPropagation(); 
    });
    
    0 讨论(0)
  • 2020-12-15 16:24

    Try live instead of on its a jquery version problem

    $('body').live('click','.ui-widget-overlay',function()
    { 
        $('#myRateSettingsPopup').dialog('close'); 
    }); 
    
    0 讨论(0)
提交回复
热议问题