-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrollspy "refresh" doesn't work, undocumented "process" does #20022
Comments
Could you post an example that demonstrates the problem? |
Also, I assume you're using Bootstrap v3.3.6 ? |
Hey there! We're automatically closing this issue since the original poster (or another commenter) hasn't yet responded to the question or request made to them 14 days ago. We therefore assume that the user has lost interest or resolved the problem on their own. Closed issues that remain inactive for a long period may get automatically locked. Don't worry though; if this is in error, let us know with a comment and we'll be happy to reopen the issue. Thanks! (Please note that this is an automated comment.) |
Hey there, I think I'm running into this too. I've created a pen to demonstrate the issue I'm having. Steps to reproduce:
At this point, refresh has been called on the scrollspy and the now centred section should be active in the menu, but it isn't. Please let me know if you'd prefer I open a new ticket, or if I've missed something. Thanks! |
@cvrebert @twbs-closer Can you re-open based on the sample code that @goodforenergy provided? |
Support for v3 has mostly ceased (see : #20631). Please let us know if this issue affects v4. |
Thanks @Johann-S, will let you know. |
While troubleshooting a related bug in this project, I ended up coming across my workaround code here. As it turns out, this may have been due to the following circumstances:
So it may be the case here that I was trying to refresh/process the element with the wrong options set, although it's been a while and the event ordering may have changed in the interim. Replacing my earlier workaround with:
seems to work as well as refresh+process for just getting the nav buttons in the right state, and avoids setting up the scrollspy without the options it needs from the HTML. |
I found #2795, but it doesn't seem to cover my case. After I load AJAX content, I call
$('[data-spy="scroll"]').scrollspy('refresh');
as is supposed to "help" the scrollspy plugin catch up. However, the navbar its is supposed to be updating (which is in the loaded content, whereas the data-spy element is the body element) still doesn't get the correct button activated.[And yes I've tried the bizarre
$('[data-spy="scroll"]').each(function () { var unusedSilliness = $(this).scrollspy('refresh'); })
"recommendation" that's in the docs right now too, no difference…]Workaround:
After reviewing the internal code, I found the "process" method that actually gets called in response to a mouse wheel. Calling that via
$('[data-spy="scroll"]').scrollspy('process');
does the trick. I've wrapped it in a try block just in case; but why doesn't refresh work as claimed?The text was updated successfully, but these errors were encountered: