Search code examples
jqueryajaxmagnific-popup

Magnific Popup ajax url in callback


I'm using Magnific Popup to confirm an action, loading the content of the popup through ajax and is working correctly.

<a class="dialog" href="/ajax/dialogs/dialog-delete.php">Delete</a>

$('.dialog').magnificPopup({ 
    type: 'ajax',
    callbacks: { 
        updateStatus: function(data) {
            if (data.status === 'ready') {
                $('.dialog_delete').on("click", function() { delete_item(object); $.magnificPopup.close(); });  
            }
        }
    }
});

The only problem is that I think is not very nice to show the url '/ajax/dialogs/dialog-delete.php', when the cursor is over the link.

For this reason I was trying to find an alternative way to do this, but I don't know how. In the documentation of the plugin I couldn't find something useful.

So, I'm a bit lost, my last trial was something like this, but it's not working and returns this error in the console b.find is not a function.

$('.dialog').magnificPopup({ 
    callbacks : {
        open : function(){
           $.ajax({
              type: "POST",
              url: "/ajax/dialogs/dialog-delete.php",
              success: function(html) {
                 //???
              }  
           });
        }
      }
});

Solution

  • You can always open the popup manually via $.magnificPopup.open method http://dimsemenov.com/plugins/magnific-popup/documentation.html#api