Popup Window stopped working after jQuery update

后端 未结 2 1547
南方客
南方客 2021-01-27 08:54

I have been using this script for a while now ( originally written by Soh Tanaka but source website is gone) - it pops up a window over a darkened page with a close button that

相关标签:
2条回答
  • 2021-01-27 09:27

    .live has been removed from 1.9. You can replace this syntax:

    $('selector').live('event', function(e) {
    

    With:

    $(document).on('event', 'selector', function(e) {
    
    0 讨论(0)
  • 2021-01-27 09:37

    You can add the migration plugin to solve this problem.

    In jQuery 1.9 a lot of deprecated methods was removed. jQuery.live is one of the removed methods, you can use jQuery.on as the replacement for live.

    But if you have other dependend libraries which uses these deprecated functionalities then you can use the jQuery migration plugin for backward compatibility. It adds almost all the removed functionalities back to jQuery.

    In your code, the live() event registration can be changed as below

    $(document).on('click', 'a.close, #fade', function() { //When clicking on the close or fade layer...
        $('#fade , .popup_block').fadeOut(function() {
            $('#fade, a.close').remove();  //fade them both out
        });
        return false;
    });
    
    0 讨论(0)
提交回复
热议问题