Skip to content
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

Feature Request: Affix destroy method #5870

Closed
maimairel opened this issue Nov 10, 2012 · 6 comments
Closed

Feature Request: Affix destroy method #5870

maimairel opened this issue Nov 10, 2012 · 6 comments
Labels

Comments

@maimairel
Copy link

It seems that affix's functionality is currently limited, it doesn't have any method to do other things like destroy.

I need to be able to turn off /on affix during runtime, is it possible to add this functionality on the next milestone?

@fat
Copy link
Member

fat commented Feb 8, 2013

you can turn the plugin off by removing .affix events from the window and resetting the class on the element

@fat fat closed this as completed Feb 8, 2013
@es128
Copy link

es128 commented Apr 2, 2013

To add to @fat's answer, to use different offset settings in different modes, you can $().removeData('affix'). Otherwise, it gets stuck with whatever was used the first time.

So the entire affix reset would look like:

$(window).off('.affix')
$(myElem).removeData('affix').removeClass('affix affix-top affix-bottom')

@Dsyko
Copy link

Dsyko commented Mar 7, 2014

If anyone has found this looking for a way to destroy an affix, and happens to be using bootstrap 3. The data name has changed to 'bs.affix'

So the way to destroy an affix in boostrap 3 is:

$(window).off('.affix')
$(myElem).removeData('bs.affix').removeClass('affix affix-top affix-bottom')

@lustremedia
Copy link

@Dsyko just the missing link I was looking for. Thanks!

@steida
Copy link

steida commented Jul 10, 2014

@Dsyko Thank you! It's shame that jQuery people does not understand importance of widget lifecycle.

@cvrebert
Copy link
Collaborator

Successor issue: #13655

@twbs twbs locked and limited conversation to collaborators Jul 10, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants
@steida @fat @Dsyko @cvrebert @lustremedia @es128 @maimairel and others