javascript - 在函数中调用 scrollspy refresh 时需要帮助

标签 javascript jquery twitter-bootstrap

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/

相关文章:

javascript - 主干 View 中的 Div id 持久性

Javascript 类 "Object #<HTMLInputElement> has no method ' 添加标签'"

javascript - 使用 json 进行组合选择

html - 如何在导航栏上居中对齐图像,对于小型设备如何将其向左移动以适应内容?

jquery - 未捕获( promise 中)TypeError : Cannot read property 'template' of null popover. js

javascript - Angular Controller 功能不会将结果从一个功能返回到另一个功能

javascript - 关于 d3.interpolate 对象的困惑

javascript - 所有选项卡内容均在页面加载时出现。我只想显示 Activity 选项卡数据

twitter-bootstrap - 流体或固定网格系统,采用响应式设计,基于 Twitter Bootstrap

JavaScript 函数不适用于渐变