tracks/app/views/notes/update.js.erb

33 lines
981 B
Text
Raw Normal View History

2010-11-19 22:45:18 +01:00
<% if @saved -%>
page_notify('notice', 'Note <%=@note.id %> saved', 5);
replace_note_form_with_updated_note();
<% else -%>
show_errors();
<% end %>
function show_errors() {
$('div#edit_error_status').html(html_for_error_messages());
$('div#edit_error_status').show();
}
function replace_note_form_with_updated_note() {
$('#<%= dom_id(@note, 'edit')%>').fadeOut(250, function() {
$('#<%= dom_id(@note, 'edit')%>').html(html_for_updated_note_form());
$('div.project_notes#<%= dom_id(@note)%>').html(html_for_updated_note_details());
$('#<%= dom_id(@note)%>').fadeIn(500);
});
}
function html_for_error_messages() {
return "<%= escape_javascript(error_messages_for('note')) %>";
}
function html_for_updated_note_form(){
return "<%= escape_javascript(render(:partial => 'note_edit_form', :object => @note)) %>";
}
function html_for_updated_note_details(){
return "<%= escape_javascript(render(:partial => 'note_details', :object => @note)) %>";
}