views:

635

answers:

2

I have a SWF movie inside of a jQuery UI tab, and the problem I'm having is that the SWF gets reloaded everytime I click away from the tab onto another tab, and then click back. I can inspect the DOM and see that the div containing the SWF is still in the DOM when I click away, so I don't know why this it seems to reload it when I click back to the tab.

I added the following CSS rules to try to prevent the display being set to: none, but the Flash movie is still reloading:

.ui-tabs .ui-tabs-hide {
    display: block !important;
    position: absolute;
    left: -10000px;
}

Update: It turns out this is related to the following Firefox bug which has been around since 2001 / Firefox 0.9. I still don't have a good workaround however.

A: 

Hello,

Some browsers (firefox for example) are reloading flash movies as soon as you do a hide/show (display: none;) on them. This is what is happening with the tab system. The only solution I know of is to

  1. have the flash with a position:absolute;
  2. listen to the event of the tab system
  3. make sure the flash is moved in and out the screen view when the tab is shown/hidden

This can become tricky if you want a multi-flash, generic solution..

I hope this will help you

Jerome WAGNER
Hello,could you elaborate on the -1 ? This is really what i have been observing on firefox. I usually put the absolutely positioned flash outside of the tab div though.
Jerome WAGNER
@Jerome WAGNER. Yeah, I accidentally clicked on the down arrow, and then tried to undo it, but now I get a message stating that "Vote too old to be changed, unless this answer is edited" -- perhaps you could make a small edit?
Raul Agrait
I did the edit. So you tried it with your css and it did not work ? I saw your bounty and will try to take a deeper look in the next days if no one else answers before ;-)
Jerome WAGNER
+2  A: 

Hello Raul, The solution mentioned earlier works in Chrome but not in Firefox for whatever reason (I am quite sure it was working some time ago). I found yet another solution :

first you need a generic rule to "hide" the content without using display:none;

/** hide the tab without using display:none; **/
.ui-tabs .ui-tabs-hide {    
display: block !important;
height: 0!important;
width: 0!important;
border:none!important;
visibility:hidden!important;

}

/** make sure your swf does not have leftover height when hidden **/
.ui-tabs .ui-tabs-hide object,
.ui-tabs .ui-tabs-hide embed {
    height: 0;
    width: 0;
}

It works for me. Tell me if if works for you ! Jerome WAGNER

Jerome WAGNER
@Jerome WAGNER: The problem with this is that in your UI, you get a really big scrollbar because the DOM still includes in its layout all of the elements for each tab, even when they're not in the active tab.
Raul Agrait
@Raul Agrait: I think I fixed your scrollbar issue with a modification I did on my answer. Tell me!
Jerome WAGNER
@Jerome WAGNER While your solution doesn't entirely solve my problem, it does help in some regards, so I'm going to accept it to grant you the bounty for providing the best answer.
Raul Agrait