.student_management
  %ul.students
    - course.students.each do |student|
      %li[student]
        = button_to "Remove", { :controller => 'courses/students', :action => 'destroy', :course_id => course.id, :id => student.id }, :confirm => "Are you sure you want to remove #{student.name} from #{course.name}?", :method => :delete
        = render :partial => "people/person", :locals => {:person => student.person}
      
  - form_tag course_students_path(course), :method => :post, :class => "add_student" do
    = select_tag 'student_id', options_from_collection_for_select(course.eligible_students, :id, :name_and_village)
    = submit_tag "Add"

:javascript
  $('document').ready(function() {
    $('.students .button-to').ajaxDelete('.student_management');
    $('.add_student').each(function(index, element) {
      element = $(element);
      var course_element = element.closest('.student_management');
      element.ajaxForm({
        url: element.attr('action') + ".js",
        success: function(responseText) {
          var data = $(responseText);
          course_element.html(data);
          ajax_up_add_student_form(data.find('.add_student'));
        }
      });
    })
  });
.student_management
  %ul.people
    - course.students.each do |student|
      %li[student]
        = button_to "Remove", { :controller => 'courses/students', :action => 'destroy', :course_id => course.id, :id => student.id }, :confirm => "Are you sure you want to remove #{student.name} from #{course.name}?", :method => :delete
        = render :partial => "people/person", :locals => {:person => student.person}
      
  - form_tag course_students_path(course), :method => :post, :class => "add_student" do
    = select_tag 'student_id', options_from_collection_for_select(course.eligible_students, :id, :name_and_village)
    = submit_tag "Add"

:javascript
  $('document').ready(function() {
    $('.people .button-to').ajaxDelete('.student_management');
    $('.add_student').each(function(index, element) {
      element = $(element);
      var course_element = element.closest('.student_management');
      element.ajaxForm({
        url: element.attr('action') + ".js",
        success: function(responseText) {
          var data = $(responseText);
          course_element.html(data);
          ajax_up_add_student_form(data.find('.add_student'));
        }
      });
    })
  });
Fix js for adding/removing students
Fix js for adding/removing students
