D
D
Dmitry2016-12-05 16:40:25
JavaScript
Dmitry, 2016-12-05 16:40:25

How to remove an event from a popup window?

Hello. There is a page (landing). I attached a click to the body and opened a link in a new tab, excluding the main content of the page.

$("body").click(function(){
    window.open('http://toster.ru',  '_blank');
  });

  $(".container").click(function(e){
    e.stopPropagation(); 
  });

  $(".mfp-container").click(function(e){
    e.stopPropagation(); 
  });


The problem is that the last line does not remove the event from the magnific popup. Obviously due to the fact that there are no window elements at the time of script initialization.
Tried through magnific options but doesn't work
$('.header__orderBlock_btnLink,.footer__orderBlock_btnLink').magnificPopup({
    type:'inline',
    removalDelay: 500,
    mainClass: 'mfp-fade popup_inline',
    showCloseBtn: true,
    closeMarkup: '<div class="mfp-close">x</div>',
    closeBtnInside: true,
    closeOnContentClick: false,
    closeOnBgClick: true,
    alignTop: false,
    fixedContentPos: true,
    callbacks: {
      open: function () {
        $("body").undind('click', clickOnBody);
      }
    }
  });


How can this problem be solved?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-12-05
@ddimonn8080

Decided like this:

$('.header__orderBlock_btnLink,.footer__orderBlock_btnLink').magnificPopup({
    type:'inline',
    removalDelay: 500,
    mainClass: 'mfp-fade popup_inline',
    showCloseBtn: true,
    closeMarkup: '<div class="mfp-close">x</div>',
    closeBtnInside: true,
    closeOnContentClick: false,
    closeOnBgClick: true,
    alignTop: false,
    fixedContentPos: true,
    callbacks: {
      open: function () {
        $("body").unbind('click');
      },
      close: function () {
        $("body").bind('click', function(){
          window.open('http://toster.ru',  '_blank');
        });
      }
    }
  });

D
dom1n1k, 2017-04-04
@dom1n1k

Something futuristic. But Futura exists in a lot of versions from different brands and even more fonts that imitate it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question