Answer the question
In order to leave comments, you need to log in
Fancybox ajax request how to get link attribute?
Hello. I use the @fancyapps/fancybox library on the site. Popups are opened by Ajax request.
Let's say there is a link -
<a class = "js-fancybox-ajax" data-type="ajax" data-src="../backend/login-form.html" href="javascript:;">Войти</a>
$(function() {
$().fancybox({
'selector': '.js-fancybox-ajax',
'touch': false,
'hideScrollbar': false,
ajax: {
settings: {
data: {'id': 123},
}
},
});
});
Answer the question
In order to leave comments, you need to log in
$('.js-fancybox-ajax').on('click', function(e){
e.preventDefault();
var $this = $(this),
data = $this.data();
$.fancybox.open({
src: data.src,
'touch': false,
'hideScrollbar': false,
ajax: {
settings: {
// Отправить всю data или (лучше) собрать новую из нужных аттрибутов
data: data,
}
}
// И т. д опции открытия fancybox
});
return !1;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question