Yannick Deltroo
Yannick Deltroo

Reputation: 521

Drag & drop across frames with jQuery UI

I would like to do this:

Is there a way to use jQuery UI draggable & droppable to achieve this? or otherwise do this in a cross-browser way, possibly with another JS library?

Upvotes: 1

Views: 5001

Answers (1)

Jose Faeti
Jose Faeti

Reputation: 12314

You can easily do this by accessing the contents inside the iframe with jQuery this way:

$( 'your-iframe' ).contents().find( 'elements-to-find' ).droppable();

To make sure the iframe contents are loaded when you run the script, you must wait for the jQuery load event of the iframe.

$('your-iframe').load(function() {

    $( 'your-iframe' ).contents().find( 'elements-to-find' ).droppable();

});

I had the same necessity of you and managed to do drag and drop between iframes this way, and everything worked correctly.

Upvotes: 1

Related Questions