tracks/app/views/contexts/create.js.erb

30 lines
820 B
Text
Raw Normal View History

<% if @saved -%>
hide_empty_message();
TracksPages.hide_errors();
TracksPages.set_page_badge(<%= @down_count %>);
add_context("<%=@context.hidden? ? 'hidden' : 'active'%>");
clear_form();
<% else -%>
TracksPages.show_errors(html_for_error_messages());
<% end -%>
function hide_empty_message() {
$('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 ? escape_javascript(render(:partial => 'context_listing', :object => @context )) : "" %>";
}
function html_for_error_messages() {
2012-04-19 00:02:42 +02:00
return "<%= escape_javascript(get_list_of_error_messages_for(@context)) %>";
}