How to get draggable to work in child window?

How to get draggable to work in child window?

Hi, I am using the latest jquery and jquery ui. The problem I have is that I open a window.

This window I have a webpage inside. If I include jquery and jquery ui into the child window directly. Everything works perfectly. 

However, I want to use jquery on the parent window to append jquery and jquery ui to the child window and the ui code inside a function. Then run the function from the parent window.

It only works if I directly add jquery and jquery ui in the child windows document by modifiying it's code.

I want to on the fly add the support and code to the window. 

I have the code in the parent window to run the function from the child window. This only works if jquery and jquery ui and the javascript code is added to the document directly and saved in the actual file.

I wan to append this to the child window and then run the function that was just appended to the child window from the parent window.

How can I do this?  currently the parent window when running the function that is appended to child window it says there's no such function.  If all this is added in statically to the file it works perfectly and the function runs. 

example:

parent window [] 

{
var send = jquery lib, jquery ui-lib;

var send = send + function starta() { javascript code here};

jquery.append(send);

window.child[].starta();
}

child window opened []
{
 send is appended into the head tags of this child window.
 This happens when the child window is already open and loaded.
I want to append above into this child window and then the function
in here from the parent window but will run on this window aka child window.
}

So the above example is what I want to do.  append jquery, jquery-ui and javascript code to child window and then run function starta from parent window but will run on the child window.

The problem is that when I run the code in this design it returns starta isn't a function error. 
however, if I manually put the code inside the child window and save it  and then run it. It works exactly as expected it runs the function without a problem from the parent window.

Above example isn't actual code but the actual design of the structure of code.  code returns no errors just that I cannot run a function if the function is appended to the child window but if I put the code directly in the child windows file it works perfectly.

Any ideas why this is happening? 


I feel the code that gets appended  isn't running because the page already loaded and since it's JavaScript code it won't execute since it's appended or added after the page loads. 

Do I need to use load to load the code in? I feel the issue here is that the code isn't executing and it's due to page already loaded and ran / executed.