Sticky '_calc' is not an available method for this element

只愿长相守 提交于 2019-12-11 09:54:01

问题


I'm trying to invoke the recalculation of the sticky header when using Foundation 6. However everything i attempt returns

We're sorry, '_calc' is not an available method for this element

Here's the declaration of the sticky element:

<div id="sticky-container" data-sticky-container>
    <div id="sticky" data-sticky data-margin-top="0" data-top-anchor="the-table" 
                     data-btm-anchor="footer:bottom" style="width: 100%">

I've tried:

$('.sticky:visible').foundation('_calc', true);
$('#sticky-container').foundation('_calc', true);
$('#sticky').foundation('_calc', true);

All 3 of these usages returns the _calc is not available.


回答1:


I think the problem is that you're not calling $(document).foundation(); directly before the call to .foundation with _calc. In my tests, I've been able to replicate the error if I call $('#sticky').foundation('_calc', true); before $(document).foundation(); is called. The issue stems from the fact that the sticky element hasn't been initialized when you're calling $('#sticky').foundation('_calc', true);

  1. Fiddle where $(document).foundation(); is called before.

  2. Fiddle where $(document).foundation(); is called after.

I'm pretty sure the above is the cause. If not, please let me know.



来源:https://stackoverflow.com/questions/36409146/sticky-calc-is-not-an-available-method-for-this-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!