Trying to connect the history api to magnific popup
found interesting content
https://github.com/EugeneDae/Magnific-Popup-Histor...but how can I use it if I have a popup called using onclick? and then the content is loaded via ajax , please help beginner
JavascriptWo_OpenLightBox function(post_id) { $('#contnet').append(''); $.get(Wo_Ajax_Requests_File(), {f:'open_lightbox', post_id:post_id}, function(data) { if (data.status == 200) { var url = post_id; history.pushState(null, title, url); document.body.style.overflow = 'hidden'; $('.lightbox-container').html(data.html); } if (data.html.length == 0) { document.body.style.overflow = 'auto'; } }); }
AJAX
if ($f == 'open_lightbox') { $html = "; if (!empty($_GET['post_id'])) { $wo['story'] = Wo_PostData($_GET['post_id']); if (!empty($wo['story'])) { $html = Wo_LoadPage('lightbox/content'); } } $data = array( 'status' => 200, 'html' => $html ); header("Content-type: application/json"); echo json_encode($data); exit(); }