Forum: Ruby on Rails Strange problem with partials and drag and drop

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
25cc4b4f00c2adcef7dd775576adad1e?d=identicon&s=25 Rajkumar S (Guest)
on 2007-02-20 15:28
(Received via mailing list)
Hi,

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(element.id)" ,
      :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)
http://img300.imageshack.us/my.php?image=firebug1do9.png

2. After I click the "check status" link
http://img83.imageshack.us/my.php?image=firebug2rz3.png

3. Even more strange is the fact that response from server does indeed
have the necessary javascript. The firebug console with response
highlighted.
http://img143.imageshack.us/my.php?image=firebug3kb2.png

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
This topic is locked and can not be replied to.