我想获取当前选定选项卡的高度,并使用 postMessage() 将值传递给它的父 iframe:
// ...
jQuery("#my-tabs").tabs({
selected: ran,
show: function( event, ui ) {
try
{
console.log(ui.panel);
var height = ui.panel.height();
if (window.postMessage && parentUrl != undefined)
parent.postMessage("height:" + height, parentUrl);
}
catch (c)
{
console.log(c.message);
}
}
});
加载页面并显示随机选择的选项卡时工作正常。
But when selecting another tab, ui.panel isn't a jQuery object anymore, so accessing height() crashes:Object #<HTMLDivElement> has no method 'height'
我正在使用带有 UI 1.8.6 的 jQuery 1.4.3 - 但找不到任何关于这种奇怪行为的信息。(也试过 jQuery('#example').bind('tabsshow' ... 同样的事情)