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

36 lines
No EOL
1 KiB
Text

<% if @saved -%>
hide_empty_message();
TracksForm.hide_errors();
set_page_badge(<%= @down_count %>);
add_context("<%=@context.hidden? ? 'hidden' : 'active'%>");
clear_form();
<% else -%>
TracksForm.show_errors(html_for_error_messages());
<% end -%>
/*
if @saved
container_name = 'list-contexts-' + (@context.hidden? ? 'hidden' : 'active')
page.insert_html :bottom, container_name, :partial => 'context_listing', :locals => { :context_listing => @context }
*/
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', :locals => { :context_listing => @context })) : "" %>";
}
function html_for_error_messages() {
return "<%= escape_javascript(error_messages_for('context')) %>";
}