11

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.

Community
  • 1
  • 1
Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117

3 Answers3

24
$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
  • 19,037
  • 12
  • 60
  • 93
  • 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 Apr 30 '10 at 21:29
  • not a shifting question. I posted a link showcasing what the problem is. It's an IE problem, not a flash problem. – Jack Marchetti Apr 30 '10 at 21:31
  • This would have worked, however, it doesn't work with Flash objects. But it's still the most correct. – Jack Marchetti May 20 '10 at 19:26
4

Have you tried:

var clone = $("#someDiv").clone(true);
$("#someDiv").remove();
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
  • 1
    +1: This works great! But I'd use `.empty()` instead of remove, that way you can append the content back into the same div. – Mottie May 02 '10 at 14:59
2

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 - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
  • 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 Apr 30 '10 at 21:22