tracks/app/views/todos/edit.js.erb
2011-02-25 14:52:02 +01:00

28 lines
715 B
Text

hide_todo();
replace_placeholder_with_form();
fill_dependency_array();
enable_rich_interaction();
function hide_todo() {
$('#<%= dom_id(@todo, 'line') %>').hide();
}
function replace_placeholder_with_form() {
$('#<%=dom_id(@todo, 'edit')%>').html(html_for_edit_form());
$('#<%=dom_id(@todo, 'edit')%>').show();
$('#<%=dom_id(@todo, 'form')%> input#todo_description').focus();
}
function fill_dependency_array() {
spec_of_todo = new Array();
<%
@todo.predecessors.each do |dep| -%>
spec_of_todo['<%=dep.id%>'] = "<%= escape_javascript(dep.specification)%>";
<% end -%>
}
function html_for_edit_form() {
return "<%= escape_javascript(render(:partial => 'todos/edit_form', :object => @todo)) %>"
}