- if note.valid?
  :plain
    $("#new_note .error").remove();
    $('#new_note textarea').val("");
    $('#preview-link').text('Preview');
    $('#preview-note').hide(); $('#note_note').show();
    NoteList.prepend(#{note.id}, "#{escape_javascript(render partial: "notes/show", locals: {note: note})}");
- else
  :plain
    $("#new_note").replaceWith("#{escape_javascript(render('form'))}");