if @saved  
  page[@todo].remove
  if @todo.completed?
    # Don't try to insert contents into a non-existent container!
    unless @prefs.hide_completed_actions?
      page.insert_html :top, "completed", :partial => 'todos/todo', :locals => { :parent_container_type => "completed" }
      page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
      page[empty_container_msg_div_id].show if @down_count == 0 && !empty_container_msg_div_id.nil?
      page.show 'tickler-empty-nd' if source_view_is(:project) && @deferred_count == 0
      page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
    end
    if @remaining_in_context == 0 && source_view_is(:todo)
      page.visual_effect :fade, item_container_id, :duration => 0.4
    end
  else
    page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id
    page.insert_html :bottom, item_container_id, :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
    page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
    page.show "empty-d" if @completed_count == 0
    page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? # If we've checked something as undone, incomplete items can't be empty
  end
  page.hide "status"
  page.replace_html "badge_count", @down_count
  if @todo.completed?  && !@todo.project_id.nil? && @prefs.show_project_on_todo_done && !source_view_is(:project)
    page.redirect_to project_path(@todo.project_id)
  end
else
  page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this action from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")  
end