我有我想要'子導航'的網站。因此,當您滾動到部分時,其工具欄將粘貼在主工具欄下方。我有這個工作,但我無法改變初始化後的頂部偏移量。該文件說:Twitter引導更改詞綴偏移
affix('refresh')
When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:
但是當我嘗試這樣我得到:
Uncaught TypeError: Object # has no method 'refresh'
這裏是我的代碼:
$(function() {
$('.sec-nav').addClass("affix-top");
var adjustNavs = function (first) {
$('.sec-nav').each(function(){
var $p = $(this).closest('.sec');
var $$ = $p.prevAll('.sec');
console.log($$);
var h = 0;
$$.each(function() { h+=$(this).outerHeight();});
console.log(h);
if (first) {
$(this).affix({offset: {top: h}});
} else {
$(this).data('affix', {b: {options: {offset:{top: h}}}});
console.log(this);
$(this).affix('refresh')
}
});
}
adjustNavs(true);
$('.sec').bind('DOMSubtreeModified', function() {
adjustNavs();
});
});
我試過的
$(this).data('affix', {b: {options: {offset:{top: h}}}});
不同變化
包括:
$(this).affix({offset: {top: h}});
我無法獲得要更改的偏移量。你如何改變詞綴插件的偏移量?謝謝。
您可以粘貼HTML塊嗎?很難說不然...如果你嘗試用'$('。sec-nav')。'affix();'替換'$('。sec-nav')。addClass(「affix-top」);''這些幫助有用?或者你已經在'.sec-nav'上獲得了'data-spy =「affix」'屬性? –