bootstrap scroll spy 文档说:
When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:
$('[data-spy="scroll"]').each(function () {
var $spy = $(this).scrollspy('refresh')
})
我想在这里实现它(http://mixitup.io/#Documentation):
$('#Grid').mixitup({
targetSelector: '.mix',
onMixLoad: null,
onMixStart: null,
onMixEnd: null
});
怎么做?
abhidev 的回答正是所需要的,这是我的问题不完整。
所以任何遇到同样问题的人,这里是解决方案(只需将“this”替换为“body”:
$('#grid').mixitup({
onMixEnd: function(){
console.log('Mixit end called');
$('[data-spy="scroll"]').each(function () {
var $spy = $('body').scrollspy('refresh')
});
console.log
}
});
最佳答案
您可以尝试在 mixit 的 onMixEnd cllback 上调用 scrollspy(refresh)。
$('#Grid').mixitup({
targetSelector: '.mix',
onMixLoad: null,
onMixStart: null,
onMixEnd: function(){
console.log('Mixit end called');
$('[data-spy="scroll"]').each(function () {
var $spy = $(this).scrollspy('refresh')
});
console.log
}
});
关于javascript - 在函数中调用 scrollspy refresh 时需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19025216/