You do not add the class affix manually. The affix function works by switching the .affix, .affix-top and .affix-bottom classes when you execute the parameters 'data-offset-top' or 'data-offset-bottom'.
Manually assigning an affix class functionally sets the element to a fixed position, so when it does not use the modal, it does not move. Of course, he will / never / move, because there is no logic for his positioning.
The corresponding affix syntax can be found on the boot site .
<div data-spy="affix" data-offset-top="200">...</div>
Unfortunately, when you scroll, this is not a document, but rather an overflow modality. My guess is affix monitors first. I created some jquery that mimics the behavior in this edited fiddle . While checking the page, you can see that the .affix class is added to the .sidebar when you scroll the point defined in jquery. I leave this for the correct position of the element (usage position: fixed).
$('.modal').on('scroll', function(){ var someThreshold = 60; if ($('.modal').scrollTop() > someThreshold) { $('.modal .sidebar').addClass('affix'); } else { $('.modal .sidebar').removeClass('affix'); } });
On the side of the note: when publishing the script, make sure that you use "col-xs- *", since using "col-md- *" forces the items to collapse into a single column in the inevitably narrow "results" area.
source share