views:

130

answers:

3

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
+1  A: 

Could it be the typo of accordion vs accordian?

eed3si9n
see other comment. corrected spelling same problem
Lance
+1  A: 

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.

Russ Cam
I did but even when I corrected that$("#tripHolder",top.document).accordion('activate',3);Still getting the same error?
Lance
Ah, I think I see what the problem might be. When you call `.html()` on the content of `#tripholder`, events bound to any child elements will be lost. What is `tripholder`? Is it the container `<div>` for the accordion?
Russ Cam
Actually that line works. It puts the contents of the msg in the the trip holder with is a DIV but you showed me this is wrong so I will post in an "Answer" so you can see the full code
Lance
Russ I corrected my original question. Hopefully you will better be able to tell now where I screwed up :-)
Lance
@Lance- possibly, am looking at it now. I had similar issues with loading content into accordion via AJAX call, the question is still open on my profile, as I never found a good solution (although to be fair, I didn't really dig deep into it).
Russ Cam
Thanks Russ, I really appriciate your help on this!!The error changed to $("#leftNav", parent.document).accordion is not a function but it still isn't working. I doubt that it make a difference but I am using a plan old iFrame and not the modal. Maybe I can trigger something in the parent that could fire the activate? You know have the iFrame hit something that is outside the accordion and have that try to activate the accordian panel since it should see the accordian already. I will let you know. And THANKS AGAIN!!
Lance
I finally got this to work last week. The answer was to create a function on the parent page that pops the accordion and call that function from the iFrame. Trying to manipulate the accordian from within the iFrame wouldn't work.
Lance
Good stuff - post your solution as the answer an accept it so others can discover the solution :)
Russ Cam
A: 

Original post fixed

Lance