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

30 lines
No EOL
756 B
Text

<% if @saved -%>
hide_empty_message();
TracksPages.hide_errors();
TracksPages.set_page_badge(<%= @down_count %>);
add_context("<%=@context.state%>");
clear_form();
<% else -%>
TracksPages.show_errors(html_for_error_messages());
<% end -%>
function hide_empty_message() {
$('div#<%=@context.state%>-contexts-empty-nd').hide();
}
function add_context(state) {
$('#list-contexts-'+state).append(html_for_context_listing());
}
function clear_form() {
$('#context-form').clearForm();
$('#context-form input:text:first').focus();
}
function html_for_context_listing() {
return "<%= @saved ? js_render('context_listing', {}, @context) : "" %>";
}
function html_for_error_messages() {
return "<%= js_error_messages_for(@context) %>";
}