<% if @saved -%> TracksPages.hide_errors(); add_note(); clear_form(); <% else -%> TracksPages.show_errors(html_for_error_messages()); <% end -%> function add_note() { $('div#notes').append(html_for_note_summary()); $('#empty-n').hide(); } function clear_form() { $('#new-note').hide(); $('#edit-note-form').clearForm(); } function html_for_error_messages() { return "<%= js_error_messages_for(@note) %>"; } function html_for_note_summary() { return "<%= @saved ? js_render('notes_summary', {}, @note) : "" %>"; }