Search code examples
javascriptjquerybpopup

bpopup onClose callback event not working


Callback event is not beinf triggerd on popup close via either modal ,close button and esc
i have tried adding it in document ready and also on click trigger noen of them worked

 $('.flipvideowrap').bind('click', function(e) {
                  e.preventDefault();
                   $('#element_to_pop_up').bPopup({
                    appendTo: 'form'
                    , zIndex: 1001
                    , easing: 'easeOutBack'              
                    , speed: 450
                    , transition: 'fadeIn'
                    , appendTo:'body'                
                    , closeClass: 'b-close'
                    , modalClose: true
                    , modalColor: '#fff'
                    , model: false   
                    ,escClose:true         
                    , position: ['auto', 42] //x, y
                  });
                   $("video").trigger("play");

                    $('#element_to_pop_up').bPopup({ onClose: function(){
                      console.log('closed');
                        var myPlayer = videojs('look_video');
                        myPlayer.pause();
                   }});

                });

Solution

  • It looks like your code actually triggers the pop twice. Try this:

    $('.flipvideowrap').bind('click', function(e) {
                  e.preventDefault();
                   $('#element_to_pop_up').bPopup({
                    appendTo: 'form'
                    , zIndex: 1001
                    , easing: 'easeOutBack'              
                    , speed: 450
                    , transition: 'fadeIn'
                    , appendTo:'body'                
                    , closeClass: 'b-close'
                    , modalClose: true
                    , modalColor: '#fff'
                    , model: false   
                    ,escClose:true         
                    , position: ['auto', 42] //x, y
                    , onClose: function(){
                      console.log('closed');
                        var myPlayer = videojs('look_video');
                        myPlayer.pause();
                   }
                  });
                   $("video").trigger("play");
                });