Reputation: 4523
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:
Upvotes: 4
Views: 17364
Reputation: 6296
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/
Upvotes: 7
Reputation: 74738
You have to pass the class name of clicked button in the function:
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();
});
});
Upvotes: 3
Reputation: 4519
Try this
function openPopup()
{
$('.ajax-call').magnificPopup({
type: 'inline',
modal: true,
});
/*$.magnificPopup({
type: 'inline',
modal: false,
});*/
$(document).on('click', '.closePopup', function (e)
{
e.preventDefault();
$.magnificPopup.close();
});
}
Upvotes: 0
Reputation: 1321
magnificPopup is not a function
error.
Please include any custom js files in your header section.
Upvotes: 0