Open poa8a opened 7 years ago
@poa8a I have a very similar use case and have tried most of what you've tried in your post with no success... Have you had any luck with this since the initialize posting?
I also needed to update magnific popup after the content dynamically changed (ajax) on a page.
This approach worked for me:
# set magnific's global instance to null
$.magnificPopup.instance = null;
# now re-create magnific from scratch
('.my-selector').magnificPopup({
...options...
});
I use Magnific to show images on a web page, and have a feature to let the user update the image caption/title. I have the caption in a data-image-description attribute on the img element. When the user updated the caption, it's updated in the database and then I update mfp.currItem as well as mfp.items array. See code below. But even if I do all these things the "old" caption is still shown, and that's even if I close the popup and re-open it. The underlying DOM structure is updated with the new caption though. I have also tried many other possible solutions to "reload" the content but to no luck:
So, if I have an image with caption "123" and I (as an end user) update it to "456", the data attribute on the img element is updated, and also the mfp.currItem.el and mfp.items[index] are updated.
The only way I can get Magnific to show the new "456" caption is to reload the page and then open Magnific again. Is there a way to achieve this through the API? If not, can someone guide me to where I should start looking in the Magnific code to do this?
Please help, I really need this to work.
The elements I use to create the Magnific:
I create the Magnific with this code:
When the caption has been updated in the database, I've tried to update mfp with this code: