2011-08-09 4 views
1

내 프로젝트에서 끌어서 놓기 기능을 만들려고 할 때 자동으로 항목을 삭제할 때 백엔드쪽에 자동으로 저장됩니다. 내 HTML 코드어떻게 장고 백엔드에서 끌어서 놓기를 저장합니까?

<script style="text/javascript"> 
$(function() { 
    $("#roles li").draggable({ 
     appendTo: "body", 
     helper: "clone", 
     }); 
    $("#item-roles li").droppable({ 
     activeClass: "ui-state-default", 
     hoverClass: "ui-state-hover", 
     accept: ":not(.ui-sortable-helper)", 
     drop: function(event, ui) { 
      alert('you drop this') 
      $("<li></li>").text(ui.draggable.text()).appendTo(this); 
     } 
    }) 
}); 

가 여기에 표시됩니다.

<div id="item-roles"> 
    <h3>Role in {{item.name|title}} Item</h3> 
     <ul> 
     <h3>Drag role here!</h3> 
     {% for item_role in item_roles %} 
      <li class="placeholder" style="list-style-type: none;"> 
       {{item_role.show_role}} <a href="#">Remove</a> 
      </li> 
     {% empty%} 
      <li>No items found</li> 
     {% endfor %} 
     </ul>    
</div> 

<div id="roles"> 
    <h3>Roles in this Show</h3> 
     <ul> 
      {% for role in roles %} 
       <li> 
       <a class="role-detail">{{ role.role_name }}</a> 
       </li> 

      {% empty %} 
       <p>No show roles </p> 
      {% endfor %} 
     </ul> 
+0

질문에 대한 언급은 잊지 마십시오. –

답변

1

당신은 자바 스크립트 "에서"당신의 장고 기능을 호출하기위한 dajaxice (및 dajax)를 사용할 수 있습니다. 이제 질문에 빠져있는 파이썬 코드를 써야합니다 ...

+0

DEF 드래그 (요청 show_id, showitem_id, showrole_id) 쇼 = Show.objects.get (PK = show_id) show_role = ShowRole.objects.get (PK = show_role_id) item_role = ShowItemRole.objects.create (= item_role show_role, show = show_role) – user683742

관련 문제