I'm trying to affix a toolbar when the user scrolls passed it. The affix portion works fine however I want to adjust the padding on my main container when the affix class actually get applied. Has some events listed However; I can't get any of them to fire. The JSfiddle doesn't look right I'm guessing cuz of the size. But essentially none of those events get fired when the affix is applied to the #nav.
$('#nav').on('affix.bs.affix', function () {
alert('Fired!');
});
You can see more of my code here.. Its essentially just the navbar given in the BS example.
/
I'm trying to affix a toolbar when the user scrolls passed it. The affix portion works fine however I want to adjust the padding on my main container when the affix class actually get applied. http://getbootstrap./javascript/#affix-usage Has some events listed However; I can't get any of them to fire. The JSfiddle doesn't look right I'm guessing cuz of the size. But essentially none of those events get fired when the affix is applied to the #nav.
$('#nav').on('affix.bs.affix', function () {
alert('Fired!');
});
You can see more of my code here.. Its essentially just the navbar given in the BS example.
http://jsfiddle/dTR4A/1/
Share Improve this question asked Feb 3, 2014 at 17:26 Christopher JazinskiChristopher Jazinski 3152 gold badges3 silver badges10 bronze badges3 Answers
Reset to default 8The affix.bs.affix
event fires when the affixed element is scrolled so if you scroll the page:
This event fires immediately before the element has been affixed.
so make your page content higher.
Demo: http://jsfiddle/4vmMd/
Encountered a similar problem.. Turns out that it was older version of bootstrap. It worked just fine with newer version. Also ensure that your content has enough height.
For future travelers falling into this issue, I was having the same issue but the above solutions did not work for me.
I found out that in a pletely remote part of my application, we have:
$(window).unbind('scroll')
$(window).off('scroll')
Which was killing the handler
for the scroll event (probably, the Affix library observes the $(window)
element in order to fire the scrolling events).
Hope this helps.