tags:

views:

142

answers:

4

I basically have the same problem in this questions:

Flash Video still playing in hidden div

I've used the .remove jquery call and this works. However, I have previous/next buttons when a user scrolls through hidden/non-hidden divs. What I need to know is, once I remove the flash object, is there a way to get it back other than refreshing the page?

Basically, can this be handled client side or am I going to need to implement some server side handling.

detach() won't work because the flash video continues to play.

I can't just hide it because the video continues to play as well.

+1  A: 

You can assign it to a variable:

var undo = $('#someDiv')

Then use the value of "undo" to re-insert the item.

$('#placeholder').html(undo)

Perhaps you're better off hiding it instead of removing it.

Diodeus
Can't hide it. The divs contain flash videos, which in every other browser, when their div is hidden, they stop playing. in IE, they keep playing, hence the need to remove it.
Jack Marchetti
+5  A: 
$myVariable = $("#removeMe").detach();

The .detach() function is explicitly made to take something out of the DOM to be put back in later. It's a good'n.

API Ref: http://api.jquery.com/detach/

Alex Mcp
+1 Hmmm. Never knew that.
Diodeus
That sounds like a Flash problem then (which I know little about). Can JS send a signal to a flash object to pause it?It's a bit hard to answer a shifting question.
Alex Mcp
not a shifting question. I posted a link showcasing what the problem is. It's an IE problem, not a flash problem.
Jack Marchetti
This would have worked, however, it doesn't work with Flash objects. But it's still the most correct.
Jack Marchetti
+1  A: 

Have you tried:

var clone = $("#someDiv").clone(true);
$("#someDiv").remove();
David Murdoch
+1: This works great! But I'd use `.empty()` instead of remove, that way you can append the content back into the same div.
fudgey
A: 

Hi How can we add the content back to the same div???

Naveen