jquery - Magnific Popup - popup within a popup. How to make "close" go to previous popup? -


i've got basic setup:

 $('.ajax-popup-link').magnificpopup({         type: 'ajax',         callbacks: {             ajaxcontentadded: function () {                 $('.image-link').magnificpopup();             };         } });  

what i'd have close event of "image-link" popup go original popup. first thought grab original element , maybe pass 2nd popup, bind close event element... when closes, automatically popsup original one.

has else done this? there better way possibly this?

probably, way achieve want take original element , reopen it. passing 2nd popup's close callback won't give anything, since never called. magnificpopup not fire open event if popup opened, because there 1 instance of magnific popup object. can check if curritem equal 1st popup's item.

var childopened,     parentitem,     $parent = $('.ajax-popup-link'); $parent.magnificpopup({     type: 'ajax',     callbacks: {         open: function () {             // triggered when 1st popup opens             // save 1st popup's item             parentitem = this.curritem;             // not register new callbacks if pass them             $('.image-link').magnificpopup();         },         close: function () {             // called twice, since opened popup twice             // not move `afterclose`. `curritem` not available there             childopened = (this.curritem !== parentitem);         },         afterclose: function () {             if (childopened) {                 // should in `afterclose` avoid conflicts                 // previous popup opening                 $parent.magnificpopup('open');             }         }     } }); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -