Home:ALL Converter>AngularJS/UI/Bootstrap remove affix from an element?

AngularJS/UI/Bootstrap remove affix from an element?

Ask Time:2013-11-19T03:15:33         Author:changus

Json Formatter

I am using AngularJS 1.2 and Bootstrap 2.3, although I think it is irrelevant that Angular is involved since this is just jQuery. I want to be able to turn the affix on and off for a particular element. I have multiple elements on my page using affix so I can't just disable all instances of the plugin on the page. Also, my problem is unrelated to screen sizes so css is not possible.

For an element for which I have added affix to:

$(element).affix();

Things I have tried that I read about online/stackoverflow to remove the affix, but have been unsuccessful:

$(element).off('.affix');

$(element).removeData('affix').removeClass('affix affix-top affix-bottom');

Is it possible to just remove the affix aspect of this element?

Any help would be great!

Author:changus,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20055911/angularjs-ui-bootstrap-remove-affix-from-an-element
m.e.conroy :

In Bootstrap 2.3 you use affix like this:\n\n<div data-spy=\"affix\" data-offset-top=\"200\">...</div>\n\n\nI would think you need to remove the data-spy attribute from an element\n\nel = $(el);\nvar affixed = el.attr('data-spy');\nif((typeof affixed != undefined) && (affixed !== false) && (affixed == 'affix'))\n el.removeAttr( \"data-spy\" );\n\n\nSomething like that I think would work. Of course you could also remove the data-offset... attribute as well if there is one.",
2013-11-18T20:17:24
yy