jQuery Accordion - 设置“活动面板”负载期间

发布于 2024-11-09 21:52:15 字数 680 浏览 0 评论 0原文

有一个奇怪的问题,我“认为”我知道问题是什么,但不知道如何解决。

我有一个包含 jQueryUI Accordion 的页面,我试图在运行时设置“Activate”,但只有在放置“Alert();”时才能使其正常工作。前!

我确实有许多 getJSON 调用来填充 Accordion 的内容(确定它必须有多少个面板),一旦完成,就需要跳转到适当的面板。

实际的调用在这里:

function jumpToAccordionDate(d,m,y){
var el3=$('#h'+d +  m +  y);
$('#accordion').accordion('activate',el3);}

以前,在创建手风琴期间,我已经通过以下方式设置了 H3 元素的 id:

$('#accordion').append('<h3 id="h' + dd + '"><a href="#">' + cDate + '</a></h3><div id="div' + dd + '"></div>').accordion('destroy').accordion();

是否有某种方式,也许在调用之前等待手风琴在 DOM 上完全完成渲染JumpToAccordionDate,或者有更好的替代方案吗?

Having a strange issue that I 'think' I know what the problem is but don't know how to resolve it.

I have a page that contains a jQueryUI Accordion, I'm trying to set the "Activate" during runtime, but I can only get this to work if I put an "Alert();" before!

I do have a number of getJSON calls that populates the contents of the Accordion (determines how many panels it has to have) and once this is complete then needs to jump to the appropriate panel.

The actual call is here:

function jumpToAccordionDate(d,m,y){
var el3=$('#h'+d +  m +  y);
$('#accordion').accordion('activate',el3);}

Previously, during the creation of the accordion, I've already set the id of the H3 element by the following:

$('#accordion').append('<h3 id="h' + dd + '"><a href="#">' + cDate + '</a></h3><div id="div' + dd + '"></div>').accordion('destroy').accordion();

Is there someway of, maybe waiting for the Accordion to totally finish rendering on the DOM before I call the jumpToAccordionDate, or is there a better alternate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与他有关 2024-11-16 21:52:15

我认为 create 事件可能会解决您的计时问题。该文档有点模糊,但您可以像这样使用它:

$("#accordion").accordion({
    create: function() {
        jumpToAccordionDate(...);
    }
});

I think the create event might solve your timing issue. The documentation is a little vague, but you could tap into it like this:

$("#accordion").accordion({
    create: function() {
        jumpToAccordionDate(...);
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文