Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open popup from another function - Magnific Popup

I want to open my popup when ajaxCall function is called.

Like this:

function ajaxCall()
{

 openPopup();

}

function openPopup()
{

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

type: 'inline',
modal: false,

});

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

}

Here is the fiddle: http://jsfiddle.net/qweWa/33/

I want this popup to open when ajaxCall function is called.

Here is the working fiddle for onclick button open popup:

http://jsfiddle.net/qweWa/27/

like image 285
Hassan Sardar Avatar asked Jan 12 '23 04:01

Hassan Sardar


1 Answers

Use the open() function

function openPopup(el) { // get the class name in arguments here
            $.magnificPopup.open({
                items: {
                    src: '#thanksModal',
                },
                type: 'inline'
            });
}

JSFiddle : http://jsfiddle.net/t5f5e5zw/2/

like image 180
crafter Avatar answered Jan 21 '23 07:01

crafter