open magnificPopup Ajax popUp with jQuery -
i'm using ajax popup magnificpopup. open popup within jquery click event don't how to that.
$('.popup').click(function() { var id = $(this).attr('rel'); url = '/test-ajax.php?id=' + id; alert("url" + url); //this shows url popup should load })
the "normal" magnific popup class looks so:
$('.simple-ajax-popup-align-top').magnificpopup({ type: 'ajax', aligntop: true, overflowy: 'scroll' });
thanks help.
assuming ajax call produces html string, can try this:
$('.popup').click(function() { var id = $(this).attr('rel'); url = '/test-ajax.php?id=' + id; $.ajax({ type: "post", url: url, success: function(result) { $('.simple-ajax-popup-align-top').magnificpopup({ aligntop: true, overflowy: 'scroll', items: { src: result, type: 'inline' } }).magnificpopup('open'); }, }); });
what code fire ajax call (documented here). on ajax success callback, triggers magnificpopup, insert result (which html string gotten ajax call) magnificpopup via "items" property (documented here , here - see section right above "public properties")
How to use jQuery Selectors? List of jQuery Selectors?
ReplyDeleteThe jQuery is the collections of scripts written in JavaScript to perform various task including the document traversal and manipulation, event handling, animation etc.