打开带有函数的手风琴面板

发布于 2024-08-09 03:58:19 字数 1229 浏览 7 评论 0原文

好的,这是完整的代码,包含拼写更正和所有内容。我仍然收到错误。

父级的代码是:

$("#leftNav").accordion({autoHeight: true});

<div id="leftNav">    <h3><a href="#">Client</a></h3>
<div>        static text    </div>
<h3><a href="#">Account Summary</a></h3>
<div>        static text    </div>
<h3><a href="#"> Profile</a></h3>
<div>        static text    </div>
<h3><a href="#">trip</a></h3>
<div>
    <div id="tripHolder">
    </div>
</div>

iFrame 的代码:

$(".bookingClass").click(function(){
     var thisBookingClass = 'bClass='+$(this).attr("id");
           $.ajax({
                type:"POST",
                url:"bookIt.jsp",
                data: thisBookingClass,
                cache:false,
                success: function(msg) {
                    $("#tripHolder",top.document).html(msg);
                    $("#leftNav",top.document).accordion('activate',3);
                 }
           });
});

我在 fire bug 中遇到的错误现在是

$("#leftNav", top.document).accordion is not a function

ok here is the full code with the spelling corrections and everything. I am still getting an error.

code for parent is :

$("#leftNav").accordion({autoHeight: true});

<div id="leftNav">    <h3><a href="#">Client</a></h3>
<div>        static text    </div>
<h3><a href="#">Account Summary</a></h3>
<div>        static text    </div>
<h3><a href="#"> Profile</a></h3>
<div>        static text    </div>
<h3><a href="#">trip</a></h3>
<div>
    <div id="tripHolder">
    </div>
</div>

the code for the iFrame :

$(".bookingClass").click(function(){
     var thisBookingClass = 'bClass='+$(this).attr("id");
           $.ajax({
                type:"POST",
                url:"bookIt.jsp",
                data: thisBookingClass,
                cache:false,
                success: function(msg) {
                    $("#tripHolder",top.document).html(msg);
                    $("#leftNav",top.document).accordion('activate',3);
                 }
           });
});

The error I am getting in fire bug is now

$("#leftNav", top.document).accordion is not a function

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

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

发布评论

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

评论(2

跨年 2024-08-16 03:58:19

您在代码中拼写了 Accordion 错误。

编辑:

我有一个工作演示,可以在Firefox(在 IE6 中尝试过,但失败),仅当“client”标头是当前选择的标头时。您可以通过在 URL 中添加 /edit 来查看代码。

这似乎是一个棘手的问题,不幸的是我现在没有时间进一步研究它。为了防止出现错误,

$("#leftNav", top.document).accordion is not a function

我必须将对 jQuery UI 脚本的引用添加到 iframe 的源中。

似乎无法从 iframe 内部访问手风琴,我不确定原因。我让激活工作的方式非常hacky,基本上再次在#leftNav上调用.accordion(),然后是.accordion('activate' ,3); 如下面的

$.ajax({
  type:"POST",
  url:"http://jsbin.com/etiju",
  data: {},
  dataType: 'html',
  cache:false,
  success: function(msg) {
    $('#tripHolder',parent.document).html(msg);
    $("#leftNav",parent.document).accordion({ autoHeight:true }).accordion('activate',3);
  }                                
});

通知所示,我还使用了 parent.document 而不是 top.document - 后者不起作用,但通常在火狐。

我希望它能让你走得更远。当我有更多时间时,我可能会回到这一点。

you've spelt accordion wrong in your code.

EDIT:

I have a Working Demo that works in Firefox (tried in IE6 but it failed), only if the "client" header is the one currently selected. You can see the code by adding /edit to the URL.

This seems to be a tricky problem to solve and unfortunately I don't have the time to look into it further at the moment. To prevent the error

$("#leftNav", top.document).accordion is not a function

I had to add a reference to the jQuery UI script to the source of the iframe.

It appears that the accordion becomes inaccessible from inside the iframe, the reason I'm not sure. The way that I got the activate to work was very hacky and basically called .accordion() on the #leftNav again, followed by .accordion('activate',3); as in the following

$.ajax({
  type:"POST",
  url:"http://jsbin.com/etiju",
  data: {},
  dataType: 'html',
  cache:false,
  success: function(msg) {
    $('#tripHolder',parent.document).html(msg);
    $("#leftNav",parent.document).accordion({ autoHeight:true }).accordion('activate',3);
  }                                
});

notice that I also used parent.document instead of top.document - the latter wasn't working but normally does in Firefox.

I hope it's got you a little further along. I may come back to this one when I have more time.

水波映月 2024-08-16 03:58:19

这可能是手风琴与手风琴的拼写错误吗?

Could it be the typo of accordion vs accordian?

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