将警报转换为magnificPopup模式

时间:2014-09-18 19:14:52

标签: jquery magnific-popup

使用magnificPopup将警报重新分解为模态弹出窗口。不确定我是否正确调用了magnificPopup。这是正确的语法吗?谢谢你的帮助!

代码:

<script>
    $(document).ready(function () {
        $('.readMore').each(function () {
            if (isDivClipped(this)) {
                $(this).wrap("<div class='readmorewrapper'></div>");
                $(this).after("<a href='#' onclick='showReadMore(this);'>Read More...</a>");
            }
        });


    });
    function showReadMore(el) {
        var modalContent = ($(el).closest('.readmorewrapper').find('.readMore').text());
        $('modalContent').magnificPopup;
    }
    function isDivClipped(el) {
        return true;
    }
</script>

1 个答案:

答案 0 :(得分:1)

所有相关文档:http://dimsemenov.com/plugins/magnific-popup/

  

工作示例:

<a class="popup-modal" href="#test-modal">Open modal</a>

<div id="test-modal" class="mfp-hide white-popup-block">
    <h1>Modal dialog</h1>
    <p>Some block of text here</p>
    <p><a class="popup-modal-dismiss" href="#">Dismiss</a></p>
</div>


$(function () {
    $('.popup-modal').magnificPopup({
        type: 'inline',
        modal: true
    });
    $(document).on('click', '.popup-modal-dismiss', function (e) {
        e.preventDefault();
        $.magnificPopup.close();
    });
});