this works for me
http://codepen.io/ryanjbonnell/pen/dqsxI
jQuery('.gallery-link').on('click', function () {
jQuery(this).next().magnificPopup('open');
});
jQuery('.gallery').each(function () {
jQuery(this).magnificPopup({
delegate: 'div',
type: 'image',
gallery: {
enabled: true,
tPrev: '',
tNext: '',
tCounter: '%curr% | %total%'
}
});
});
Answer from Nikolay Popov on Stack Overflowthis works for me
http://codepen.io/ryanjbonnell/pen/dqsxI
jQuery('.gallery-link').on('click', function () {
jQuery(this).next().magnificPopup('open');
});
jQuery('.gallery').each(function () {
jQuery(this).magnificPopup({
delegate: 'div',
type: 'image',
gallery: {
enabled: true,
tPrev: '',
tNext: '',
tCounter: '%curr% | %total%'
}
});
});
$('button').click(function(){
//do something here
});
Probably too late to initial asker, but might help someone else...
No href attribute to button, you need to use "mfp-X" class names instead.
For me "mfp-inline" did the trick, but for ajax you need probably something like this:
<button class="ajax-popup-link mfp-ajax green" data-mfp-src="#div_element">Enter Now</button>
...
$('.ajax-popup-link').magnificPopup();
(Not sure if in ajax you need this, but there is also "data-mfp-src" attr that shows where dialog div is...)
I have another solution. You can make use of magnific-popup API for popup loaded via ajax:
<button data-ajax-popup-url="URL">Изменить</button>
...
$('[data-ajax-popup-url]').click(function() {
$.ajax({
url: $(this).data('ajax-popup-url')
})
.success(function(response, textStatus, request){
var popup = $(response);
$.magnificPopup.open({
items: {
src: popup, // can be a HTML string, jQuery object, or CSS selector
type: 'inline'
}
});
});
return false;
});
If you're using jQuery you could just listen for the window load event and then call the open method for your Magnific Popup like so:
(function($) {
$(window).load(function () {
// retrieved this line of code from http://dimsemenov.com/plugins/magnific-popup/documentation.html#api
$.magnificPopup.open({
items: {
src: 'someimage.jpg'
},
type: 'image'
// You may add options here, they're exactly the same as for $.fn.magnificPopup call
// Note that some settings that rely on click event (like disableOn or midClick) will not work here
}, 0);
});
})(jQuery);
I was able to get a timed modal working using jquery's setTimeout function, Just wrap .magificpopup in the settimeout function to set a delay. Change the value of 5000 (5 seconds) to whatever value you want.
See below:
$(document).ready(function () {
setTimeout(function() {
if ($('#myModal').length) {
$.magnificPopup.open({
items: {
src: '#myModal'
},
type: 'inline'
});
}
}, 5000);
});
You can use the focus option of magnific-popup.
$.magnificPopup.open({
items : {
type : 'inline',
src : '#idOfInlinePopUP'
},
focus: '#closeButton',
closeOnBgClick:false,
enableEscapeKey:false
}, 0);
Code of button:
<input type="button" value="close" onclick="$.magnificPopup.close();" id="closeButton">
In this code the focus option consists of the ID of the button which you want to open. And src has to contain the id of the inline popup.
If you are able to open your popup successfully then you just need to add focus attribute with ID of the button you want to click on enter click.
In this answer, on opening of popup the default focus will be on closeButton. On clicking this button the popup will close.
you should use events to focus on save button when popup opened. fiddle
$('.popup-modal').magnificPopup({
...
callbacks: {
open: function() {
$('.popup-modal-save').focus();
},
}
});