You can use $(this.element)
to refer to $(this)
inside any fancybox callback.
To get the data-id
attribute's value (or any or more attributes), as in your example, you can use the afterLoad
callback like :
$(".fancybox-buttons").fancybox({
afterLoad: function () {
// get (data) attributes from current element
var attr1 = $(this.element).data("id"),
attr2 = $(this.element).data("fancybox-group");
alert(attr1 +", "+attr2);
}
});
See JSFIDDLE