Javascript 从另一个功能打开弹出窗口-放大弹出窗口

Javascript 从另一个功能打开弹出窗口-放大弹出窗口,javascript,jquery,popup,magnific-popup,Javascript,Jquery,Popup,Magnific Popup,我想在调用ajaxCall函数时打开弹出窗口 像这样: function ajaxCall() { openPopup(); } function openPopup() { $('.popup-modal').magnificPopup({ type: 'inline', modal: false, }); $(document).on('click', '.closePopup', function (e) { e.p

我想在调用ajaxCall函数时打开弹出窗口

像这样:

function ajaxCall()
{

 openPopup();

}

function openPopup()
{

$('.popup-modal').magnificPopup({

type: 'inline',
modal: false,

});

$(document).on('click', '.closePopup', function (e) 
            {
                e.preventDefault();
                $.magnificPopup.close();
            });

}
这是小提琴:

我希望在调用ajaxCall函数时打开此弹出窗口

以下是onclick按钮打开弹出窗口的工作小提琴:


放大弹出窗口不是一个函数
错误。 请在标题部分包含任何自定义js文件。

试试这个

function openPopup()
        {

            $('.ajax-call').magnificPopup({

            type: 'inline',
            modal: true,

        });

        /*$.magnificPopup({



 type: 'inline',
        modal: false,

    });*/

    $(document).on('click', '.closePopup', function (e) 
                {
                    e.preventDefault();
                    $.magnificPopup.close();
                });

    }

您必须在函数中传递单击按钮的类名:

function openPopup(el) { // get the class name in arguments here
   $('.'+el).magnificPopup({ // use it here
      type: 'inline',
      modal: false
   });
}

$(function () {
   $('.ajax-call').click(function (e) {
      openPopup(this.className); //<----pass the clicked button's class name
   });
   $(document).on('click', '.closePopup', function (e) {
      e.preventDefault();
      $.magnificPopup.close();
   });
});
函数openPopup(el){//在此处获取参数中的类名
$('..+el).magnificPopup({//在此处使用它
键入:“内联”,
模态:假
});
}
$(函数(){
$('.ajax调用')。单击(函数(e){
openPopup(this.className);//使用open()函数


JSFIDLE:

$。放大弹出窗口不是函数-->错误!请更正请现在查看我的帖子。我已经添加了一个可以在onclick按钮和ajax函数上工作的工作小提琴?这里不需要ajax函数。我只想在调用ajaxCall函数时打开此弹出窗口。请现在查看我的帖子。我已经添加了一个可以在onclick按钮上的rks现在可以工作了,但是调用
ajaxCall()
时会出现什么错误?我不想在单击按钮时绑定它。我希望在任何时候ajaxCall()时打开此弹出窗口被调用。这是我试图做的事情:但它没有打开我的弹出窗口。我不想将它绑定到按钮上。应该有一个通用函数
function openPopup(el) { // get the class name in arguments here
            $.magnificPopup.open({
                items: {
                    src: '#thanksModal',
                },
                type: 'inline'
            });
}