tags:

views:

175

answers:

3

My overall aim is to create an editor which I can skin using jQuery UI (by creating a custom toolbar which uses integration calls), using TinyMCE.

Lets say I have a TinyMCE editor on a page. The actual editor is an iFrame contained inside a lot of horrible table code, which is also where the current (to be scrapped) toolbar is. I want just the iframe inside a div - ideally get rid of the table code.

So...I want to transform:

<table>
    <tr>
        <td><iframe id="xyz"></iframe></td>
    </tr>
</table>

into

<div id="test">
    <iframe id="xyz"></iframe>
</div>

So far, I've tried using:

$('#xyz').clone(true).appendTo('#test');

Which clones the iframe, but no content inside it.

Is there a way to make this work?

If not, can I somehow strip the table code from around the iFrame away?

If I cant do that, I'll think I'll have to keep the table code.

A: 
$('table').replaceWith($('iframe:first'));

Try that... It replaces the table with the inner iframe.

CodeJoust
Looks like it should work, but table is getting replaced with nothing...
Josh
+1  A: 

How about:

// http://api.jquery.com/replaceWith/
$('table:has(#xyz)').replaceWith($('#xyz'));
// http://api.jquery.com/wrap/
$('#xyz').wrap('<div id="test" />');
artlung
Kind of the same as what the code I tried was doing...its moving the iFrame ok, but not the content inside it - firebug just shows empty head and body tags.
Josh
It may matter what's in there, and when it gets loaded. You may need to reload the content into your `iframe`.
artlung
A: 

Couldn't get this working properly, so instead got rid of the TinyMCE UI with a bit of CSS.

Thanks for all the suggestions though!

Josh