Using Magnific Popup, I'd like to access the data attributes of the calling object/link so that I can pass it in to the popup using POST. Code:
$('.editRecord').magnificPopup({
type: 'ajax',
preloader: false,
ajax: {
settings: {
method: "POST",
data: {
recordID: $(this).data("recordid"),
field1: $(this).data("field1"),
// similar with the rest of the fields
}
}
}
});
This doesn't work because $(this)
seems to actually refer to the document object.
I found this question and have tried all the suggestions in the answers, but none seem to work as this is not in a callback, it's in the settings. Have tried:
recordID: $.magnificPopup.instance.st.el.data("recordid")
and
recordID: $.magnificPopup.instance.currItem.el[0].data("recordid")
But I get error messages that $.magnificPopup.instance.currItem
and $.magnificPopup.instance.st
are undefined. $.magnificPopup.instance
is defined, but I don't see any attribute that holds the current item.
How can I access the calling object from within the MagnificPopup definition?