Twitter Bootstrap: Affix not triggering in single page application

a 夏天 提交于 2019-12-10 14:16:47

问题


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">

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?


回答1:


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



来源:https://stackoverflow.com/questions/17282967/twitter-bootstrap-affix-not-triggering-in-single-page-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!