Strange problem with partials and drag and drop


I am playing with a small test app for drag and drop. The structure is as follows:

<div id="update_status">   <div id="queue_list">     <ul>       <li id="id1001" class="queue_item" style="position: relative;"> 1001 11384</li>       <script type="text/javascript"> //The javascript appears below     </ul>   </div>   <div id="agent_list" style="position: relative;">     <ul>       <li class="agent_item">Test User (AGENT_IDLE)</li>     </ul>   </div> </div>

The javascript fragment in queue_list <ul><li> is

<script type="text/javascript"> //<![CDATA[ new Draggable("id1001", {ghosting:true, revert:true}) //]]> </script>

The view code for generating this consists of 3 partials,

_update_status.rhtml <div id="queue_list">   <%= render(:partial => 'update_queue') -%> </div> <div id="agent_list">   <%= render(:partial => 'update_agent') -%> </div>

_update_queue.rhtml <ul> <% @queue.each do |q| -%> <% domid = "id#{q[:callerid]}" -%> <li class="queue_item" id='<%= domid -%>'> <%= q[:callerid]-%> <%= q[:wait] -%></li> <%= draggable_element domid, :ghosting=>true, :revert=>true %> <% end -%> </ul>

_update_agent.rhtml <ul> <%@agent.each do |q| -%> <li class="agent_item"><%= q[:name] -%> (<%=q[:status]-%>)</li> <% end -%> </ul>

main view is index.rhtml

<div id='update_status'>   <%= render(:partial => 'update_status') -%> </div>

<%= link_to_remote 'Check Status...',     :url => {:action => 'index'},     :update => 'update_status' %>

<%= drop_receiving_element('agent_list',       :accept => 'queue_item',       :hoverclass => 'hover',       :with => "'queue=' + encodeURIComponent(" ,       :url => {:action=>:index})%>

This just defined the update_status div and a "check status" link. In the controller I have code like this

    if request.xml_http_request?       render :partial => "update_status", :layout => false     end

All pretty standard stuff.

Now When I do a full page refresh I get the full code and I am able to drag and drop, but strangely if I click the "check status" link the java script in queue_list <ul><li> is missing. To illustrate further let me attach some screen shot of firebug with and with out problem.

1. After a full refresh (via browser reload button)

2. After I click the "check status" link

3. Even more strange is the fact that response from server does indeed have the necessary javascript. The firebug console with response highlighted.

I am pulling my hair out due to this issue for the past 3 days, If you need any more info please feel free to ask.

Thanks for reading, and hopefully, for answering

regards, raj