2015-04-06 67 views
1

在我的项目中,我使用了宏观弹出窗口。我需要用不同的选项实现2个弹出窗口(另一个弹出窗口)。首先只使用closeOnBgClick,然后使用closeOnBgClick和closeOnContentClick。弹出窗口内的宏伟弹出框

$('.popup-with-form').magnificPopup({ 
    type: 'inline', 
    preloader: false, 
    closeOnBgClick: true 
}); 
$('.popup-content-click').magnificPopup({ 
    alignTop: true,  
    type: 'inline', 
    preloader: false, 
    modal: true, 
    closeOnBgClick: true, 
    closeOnContentClick:true 
}); 

在这里你可以明白我的意思:http://jsfiddle.net/pamjaranka/p1u2xdun/3/ 的问题是,第二弹出被忽略,它的选择和使用相同的选项,第一个弹出。为了清晰起见,我添加了“alignTop:true”,这也是行不通的。 有没有可能修复它? 感谢您的帮助。

回答

1

出现一旦弹出窗口打开后,您需要关闭它,然后调用第二个弹出式打开方法,否则第一个窗口的设置会先行,因此,叠加窗口总是关闭弹出窗口。这是我在你的JS代码做了一个简短的变化:

// Assign on click behaviour to the button in the first pop-up 
$('.popup-content-click').on('click', openPopup); 

// on click handler 
function openPopup(){ 
    //Closing the already opened pop-up  
    $.magnificPopup.close(); 
    //wait a bit then open the new pop-up 
    setTimeout(function(){ 
    $.magnificPopup.open({ 
     items:{src: '#result-again'}, 
     type: 'inline', 
     closeOnBgClick: false, 
     closeOnContentClick:true 
     }); 
    }, 100); 
} 

Here is the jsfiddle for that

+0

这工作!非常感谢。对不起,但我不能将你的答案标记为有用,直到我有足够的声望。 – 2015-04-06 10:23:47

+0

不客气。 – mzografski 2015-04-06 11:37:22