<%= remote_star_icon(todo) %>
<%= remote_toggle_checkbox(todo) %>
diff --git a/app/views/todos/_update_successful.js.erb b/app/views/todos/_update_successful.js.erb
index 40315920..2403adb0 100644
--- a/app/views/todos/_update_successful.js.erb
+++ b/app/views/todos/_update_successful.js.erb
@@ -29,7 +29,9 @@ remove_todo: function(next_steps) {
});
},
add_to_existing_container: function(next_steps) {
- $('#<%= item_container_id(@todo) %>_items').append(<%=object_name%>.html_for_todo());
+ var container = $('#<%= item_container_id(@todo) %>_items');
+ container.append(<%=object_name%>.html_for_todo());
+ TracksPages.sort_container(container);
<% if source_view_is_one_of(:calendar) -%>
next_steps.go();
<% if (@target_context_count==1) || ( (@todo.deferred? || @todo.pending?) && @remaining_deferred_or_pending_count == 1) -%>
@@ -55,7 +57,8 @@ add_to_existing_container: function(next_steps) {
<% end -%>
},
replace_todo: function(next_steps) {
- $('#<%= dom_id(@todo) %>').html(<%=object_name%>.html_for_todo());
+ $('#<%= dom_id(@todo) %>').replaceWith(<%=object_name%>.html_for_todo());
+ TracksPages.sort_container($('#<%= item_container_id(@todo) %>_items'));
next_steps.go();
},
hide_container: function(next_steps) {
diff --git a/app/views/todos/create.js.erb b/app/views/todos/create.js.erb
index e7d35b4a..4e36a99d 100644
--- a/app/views/todos/create.js.erb
+++ b/app/views/todos/create.js.erb
@@ -49,7 +49,10 @@
function add_todo_to_existing_container(next_steps) {
$('#<%= empty_container_msg_div_id %>').hide();
- $('#<%= item_container_id(@todo) %>_items').append(html_for_new_todo());
+ var container = $('#<%= item_container_id(@todo) %>_items');
+ container.append(html_for_new_todo());
+ TracksPages.sort_container(container);
+
$('#<%= item_container_id(@todo) %>').slideDown(500, function() {
$('#<%= dom_id(@todo) %>').effect('highlight', {}, 2000 );
next_steps.go();
diff --git a/app/views/todos/destroy.js.erb b/app/views/todos/destroy.js.erb
index fa895ef5..b6d14bd8 100644
--- a/app/views/todos/destroy.js.erb
+++ b/app/views/todos/destroy.js.erb
@@ -54,7 +54,9 @@ function show_new_todo_if_todo_was_recurring() {
<% if @todo.from_recurring_todo? -%>
<% unless @new_recurring_todo.nil? || @new_recurring_todo.deferred? -%>
TodoItemsContainer.ensureVisibleWithEffectAppear("<%=item_container_id(@new_recurring_todo)%>");
- $('#<%=item_container_id(@new_recurring_todo)%>_items').append(html_for_new_recurring_todo());
+ var container = $('#<%=item_container_id(@new_recurring_todo)%>_items');
+ container.append(html_for_new_recurring_todo());
+ TracksPages.sort_container(container);
$('#<%= dom_id(@new_recurring_todo, 'line')%>').effect('highlight', {}, 2000 );
TracksPages.page_inform("<%=t('todos.recurring_action_deleted')%>");
<% else -%>
@@ -75,11 +77,15 @@ function activate_pending_todos() {
if source_view_is_one_of(:project,:tag) -%>
$('#<%= dom_id(t) %>').fadeOut(400, function() {
$('#<%= dom_id(t) %>').remove();
- $('#<%= item_container_id(t) %>_items').append("<%= html %>");
+ var container = $('#<%= item_container_id(t) %>_items');
+ container.append("<%= html %>");
+ TracksPages.sort_container(container);
<%= "$('#deferred_pending_container-empty-d').show();".html_safe if @remaining_deferred_or_pending_count==0 -%>
});
<% else -%>
- $('#<%= item_container_id(t) %>_items').append("<%= html%>");
+ var container = $('#<%= item_container_id(t) %>_items');
+ container.append("<%= html%>");
+ TracksPages.sort_container(container);
<% end -%>
TodoItems.highlight_todo('#<%= dom_id(t, 'line')%>');
<% end -%>
diff --git a/app/views/todos/remove_predecessor.js.erb b/app/views/todos/remove_predecessor.js.erb
index 803baa91..7733cc99 100644
--- a/app/views/todos/remove_predecessor.js.erb
+++ b/app/views/todos/remove_predecessor.js.erb
@@ -10,7 +10,7 @@
<% end -%>
function replace_updated_predecessor() {
- $('#<%= dom_id(@predecessor) %>').html( html_for_predecessor() );
+ $('#<%= dom_id(@predecessor) %>').replaceWith( html_for_predecessor() );
}
function regenerate_predecessor_family() {
@@ -33,7 +33,9 @@ function update_successor() {
$('#c<%= @successor.context_id %>').fadeIn(500, function() {});
$('#no_todos_in_view').slideUp(100);
<% end -%>
- $('#<%=item_container_id(@successor)%>').append(html_for_new_successor());
+ var container = $('#<%=item_container_id(@successor)%>_items');
+ container.append(html_for_new_successor());
+ TracksPages.sort_container(container);
$('#<%= dom_id(@successor, 'line')%>').effect('highlight', {}, 2000 ); <%
elsif @successor.deferred? -%>
$('#<%= dom_id(@successor)%>').html(html_for_new_successor()); <%
diff --git a/app/views/todos/toggle_check.js.erb b/app/views/todos/toggle_check.js.erb
index 6729a805..fc0f8dec 100644
--- a/app/views/todos/toggle_check.js.erb
+++ b/app/views/todos/toggle_check.js.erb
@@ -64,7 +64,9 @@ var <%= object_name %> = {
next_steps.go();
},
add_todo_to_container: function(next_steps) {
- $('#<%= item_container_id(@todo) %>_items').append(<%=object_name%>.html_for_todo());
+ var container = $('#<%= item_container_id(@todo) %>_items');
+ container.append(<%=object_name%>.html_for_todo());
+ TracksPages.sort_container(container);
<% if should_make_context_visible -%>
$('#<%= item_container_id(@todo) %>').slideDown(500, function() {
$("#<%= empty_container_msg_div_id %>").slideUp(100);
@@ -82,7 +84,9 @@ var <%= object_name %> = {
<% # show new todo if the completed todo was recurring
if @todo.from_recurring_todo?
unless @new_recurring_todo.nil? || (@new_recurring_todo.deferred? && !source_view_is(:deferred)) -%>
- $('#<%= item_container_id(@new_recurring_todo) %>_items').append(<%=object_name%>.html_for_recurring_todo());
+ var container = $('#<%= item_container_id(@new_recurring_todo) %>_items');
+ conainer.append(<%=object_name%>.html_for_recurring_todo());
+ TracksPages.sort_container(container);
$('#c<%= @new_recurring_todo.context_id %>').slideDown(500, function() {
<%=object_name%>.highlight_updated_recurring_todo(next_steps);
});
@@ -123,11 +127,15 @@ var <%= object_name %> = {
if source_view_is_one_of(:project,:tag) -%>
$('#<%= dom_id(t) %>').slideUp(400, function() {
$('#<%= dom_id(t) %>').remove();
- $('#<%= item_container_id(t) %>_items').append("<%= html %>");
+ var container = $('#<%= item_container_id(t) %>_items');
+ container.append("<%= html %>");
+ TracksPages.sort_container(container);
<%= "$('#deferred_pending_container-empty-d').show();".html_safe if @remaining_deferred_or_pending_count==0 -%>
});
<% else -%>
- $('#<%= item_container_id(t) %>_items').append("<%= html%>");
+ var container = $('#<%= item_container_id(t) %>_items');
+ container.append("<%= html%>");
+ TracksPages.sort_container(container);
<% end -%>
TodoItems.highlight_todo('#<%= dom_id(t)%>');
<% end -%>