tracks/app/views/notes/update.js.erb
2014-08-13 15:33:32 +02:00

27 lines
No EOL
856 B
Text

<% if @saved -%>
TracksPages.hide_errors();
TracksPages.page_inform("<%= t('notes.save_status_message', id: @note.id) %>");
replace_note_form_with_updated_note();
<% else -%>
TracksPages.show_errors(html_for_error_messages());
<% end %>
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 "<%= js_error_messages_for(@note) %>";
}
function html_for_updated_note_form(){
return "<%= js_render('note_edit_form', {}, @note) %>";
}
function html_for_updated_note_details(){
return "<%= js_render('note_details', {}, @note) %>";
}