JQUERY UI Accordion 在窗口调整大小时调整大小?
我正在使用 JQUERY UI Accordion 模块:
<script type="text/javascript">
$(function() {
$("#sidebar_column_accordion").accordion({
fillSpace: true,
icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-minus' }
});
});
</script>
通过使用 fillSpace 选项,手风琴占据了我想要的窗口的整个高度。问题是它计算页面加载的高度,如果用户调整浏览器的大小,它不会调整...
有没有办法让手风琴在调整浏览器窗口大小时重新计算高度/大小?
谢谢
I'm using the JQUERY UI Accordion module:
<script type="text/javascript">
$(function() {
$("#sidebar_column_accordion").accordion({
fillSpace: true,
icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-minus' }
});
});
</script>
By using the fillSpace option, the accordion takes up the entire height of the window which I want. Problem is it calculate the height on page load, and if the user resizes their browser, it does not adjust...
Is there a way to have the accordion recalculate the height/size when the browser window is resized?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 jQuery UI 1.9 中,删除了调整大小方法。添加了刷新方法,该方法更加稳健,并且在这种情况下也适用。
In jQuery UI 1.9 the resize method was removed. The refresh method was added which is more robust and will work in this case also.
貌似已经更新为“刷新”了
It looks like this has been updated to "refresh"
在手风琴声明中设置 autoHeight: 'content'。这将使 div 使用内容的原生高度:
请参阅此处了解更多信息: http:// /jqueryui.com/accordion/#no-auto-height
Set autoHeight: 'content' in the accordion decalaration. This will make the div use the native height of the content:
See here for more info: http://jqueryui.com/accordion/#no-auto-height
发布的其他解决方案对我不起作用,尽管它们很接近。
使用 heightStyle:fill 定义手风琴,如下所示:
创建一个函数来计算和设置高度。请注意,我必须同时执行这两项操作,设置高度,然后在手风琴上调用刷新。缺一不可。
在页面加载和窗口大小调整时调用此函数。
The other solutions posted did not work for me, though they were close.
Define your accordion using heightStyle:fill, like so:
Create a function to calculate and set the height. Note that I had to do both, set the height and then call refresh on the accordion. One won't work without the other.
Call this function on both page load and window resize.