简体   繁体   English

打开具有功能的手风琴面板

[英]Open an accordion panel with 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 : 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

难道是手风琴与手风琴的错字?

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. 我有一个可以在Firefox中运行的工作演示 (在IE6中试用,但失败了),仅当“ client”标头是当前选定的标头时才可以。 You can see the code by adding /edit to the URL. 您可以通过在URL中添加/ edit来查看代码。

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. 我必须在iframe的源代码中添加对jQuery UI脚本的引用。

It appears that the accordion becomes inaccessible from inside the iframe, the reason I'm not sure. 似乎手风琴无法从iframe内部访问,这是我不确定的原因。 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); 我使激活工作的方式非常棘手,基本上在#leftNav再次调用#leftNav .accordion() ,随后是#leftNav .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. 请注意,我还使用了parent.document而不是top.document - top.document无法工作,但通常在Firefox中可以使用。

I hope it's got you a little further along. 我希望它能使您走得更远。 I may come back to this one when I have more time. 当我有更多的时间时,我可能会回到这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM