Newer
Older
dmpopidor / app / views / plans / create.js.erb
@briley briley on 4 May 2017 800 bytes added new create plan page
$("#available-templates").html("").hide();

<% if @templates.nil? %>
  $(".main_page_content").prepend('<p id="main-page-alert" class="alert alert-notice" style="display:none"><p class="alert alert-notice"><%= raw notice %></p></p>');
  $(".form-submit").prop("disabled", true);
	
<% elsif @templates.count > 1 %>
  // Clear the existing contents of the modal and then display template combobox
  $("#available-templates").html("<%= escape_javascript(render partial: 'available_templates') %>").fadeIn(); 
  $(".form-submit").prop("disabled", true);

<% else %>
  // Only one template so fill in the id
  $("#available-templates").html('<input type="hidden" id="plan_template_id" name="plan[template_id]" value="<%= @templates.first.id %>" />');
  $(".form-submit").prop("disabled", false);
<% end %>