Magnific 弹出窗口在 Datatables 的第二页上不起作用
Magnific popup does not work on second page of Datatables
我创建了一个数据表并将图像列添加到数据表中。当我单击图像时,我想在弹出窗口中打开图像。它适用于数据表的第一页,但是当我传递到第二页时,它不起作用。此外,我将 alert() 用于测试第二页事件,并且 alert() 有效,但弹出窗口无效。
请检查我的片段: https://jsfiddle.net/f08qdeq2/20/
我该如何解决这个问题,有什么想法吗?谢谢
$(document).ready(function() {
var table = $('#datatable').dataTable({
aLengthMenu: [
[1, 2],
[1, 2]
],
iDisplayLength: 1
});
});
$(this.document).ready(function() {
$('.image-popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: false,
fixedContentPos: true,
image: {
verticalFit: true
},
zoom: {
enabled: true,
duration: 300 // don't foget to change the duration also in CSS
},
});
});
$(document).on('click', '.image-popup', function() {
alert('You Clicked Image');
//$('.image-popup-no-margins').magnificPopup({
//Some Working code here
//});
})
您应该使用 fnDrawCallback
来初始化您的弹出窗口。试试这个...
$(document).ready(function() {
var table = $('#datatable').dataTable({
aLengthMenu: [
[1, 2],
[1, 2]
],
iDisplayLength: 1,
"fnDrawCallback": function () {
$('.image-popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: false,
fixedContentPos: true,
image: {
verticalFit: true
},
zoom: {
enabled: true,
duration: 300 // don't foget to change the duration also in CSS
},
});
}
});
});
$(document).on('click', '.image-popup', function() {
alert('You Clicked Image');
})
只需添加它即可用于普通点击事件,基于此您可以对模型(弹出窗口)执行任何操作。
$(document).on('click', '.image-popup', function() {
alert('You Clicked Image');
})
我创建了一个数据表并将图像列添加到数据表中。当我单击图像时,我想在弹出窗口中打开图像。它适用于数据表的第一页,但是当我传递到第二页时,它不起作用。此外,我将 alert() 用于测试第二页事件,并且 alert() 有效,但弹出窗口无效。
请检查我的片段: https://jsfiddle.net/f08qdeq2/20/
我该如何解决这个问题,有什么想法吗?谢谢
$(document).ready(function() {
var table = $('#datatable').dataTable({
aLengthMenu: [
[1, 2],
[1, 2]
],
iDisplayLength: 1
});
});
$(this.document).ready(function() {
$('.image-popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: false,
fixedContentPos: true,
image: {
verticalFit: true
},
zoom: {
enabled: true,
duration: 300 // don't foget to change the duration also in CSS
},
});
});
$(document).on('click', '.image-popup', function() {
alert('You Clicked Image');
//$('.image-popup-no-margins').magnificPopup({
//Some Working code here
//});
})
您应该使用 fnDrawCallback
来初始化您的弹出窗口。试试这个...
$(document).ready(function() {
var table = $('#datatable').dataTable({
aLengthMenu: [
[1, 2],
[1, 2]
],
iDisplayLength: 1,
"fnDrawCallback": function () {
$('.image-popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: false,
fixedContentPos: true,
image: {
verticalFit: true
},
zoom: {
enabled: true,
duration: 300 // don't foget to change the duration also in CSS
},
});
}
});
});
$(document).on('click', '.image-popup', function() {
alert('You Clicked Image');
})
只需添加它即可用于普通点击事件,基于此您可以对模型(弹出窗口)执行任何操作。
$(document).on('click', '.image-popup', function() {
alert('You Clicked Image');
})