Twitter Bootstrap:Affix不在单页应用程序中触发 [英] Twitter Bootstrap: Affix not triggering in single page application

查看:86
本文介绍了Twitter Bootstrap:Affix不在单页应用程序中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个单页应用程序,并使用Twitter Bootstrap。我正在尝试像这样使用Affix:

I am doing a Single Page Application and using Twitter Bootstrap. I am trying to use the Affix like so:

<div data-spy="affix" data-offset-top="100">

当我刷新页面时,一切正常,引导词缀添加了这样的类:

When I refresh the page, everything works fine, the bootstrap affix adds a class like so:

<div class="affix-top" data-spy="affix" data-offset-top="100">

当我超过100px后,它将其更改为class = affix。但是,如果我单击此页面并返回,它将不再向我的div添加任何类。实际上,它根本不会触发引导程序中的功能来设置检查位置等操作。

and after I go past 100px, it changes it to class="affix". However, if I click off this page and come back, it no longer adds any classes to my div. In fact, it does not trigger the function in bootstrap at all to set the actions to check the position, etc.

任何有关如何手动触发的见解都会很棒

Any insight would be great in how I can manually trigger it when I need to?

推荐答案

您可能需要使用
<$ c $之类的东西重新初始化词缀插件c> $('。affix-container')。affix({offset:{top:100}}); 重新绘制页面时。

You might need to reinitialize the affix plugin with something like $('.affix-container').affix({offset: { top: 100 }}); when the page is redrawn.

这篇关于Twitter Bootstrap:Affix不在单页应用程序中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆