<%= link_to "Add Item", "#", id: "add-item" %>

<div class="lesson-plan-items"></div>

<script type="text/javascript">
 var index = 1;
 var addItem = function(attributes) {
   var attributes = _.extend((attributes || {}), {index: index})
   var template = HandlebarsTemplates['lesson_plan_items/new'](attributes);
   index++;
   $(".lesson-plan-items").append(template);
   initializeTimepicker();
 };

 $("#add-item").click(addItem);

 <% items.each do |item| %>
   <%= "var attributes = JSON.parse('#{item.to_json}\');".html_safe %>
   <%= "attributes = _.pick(attributes, 'subject', 'start', 'end');".html_safe %>
   <%= "if(attributes.start) { attributes.start = moment.utc(attributes.start).format('HH:mma'); }".html_safe %>
   <%= "if(attributes.end) { attributes.end = moment.utc(attributes.end).format('HH:mma'); }".html_safe %>
   <%= "addItem(attributes);".html_safe %>
 <% end %>
</script>

<%= link_to "Add Item", "#", id: "add-item" %>

<div class="lesson-plan-items"></div>

<script type="text/javascript">
 var index = 1;
 var addItem = function(attributes) {
   var attributes = _.extend((attributes || {}), {index: index})
   var template = HandlebarsTemplates['lesson_plan_items/new'](attributes);
   index++;
   $(".lesson-plan-items").append(template);
   initializeTimepicker();
 };

 $("#add-item").click(addItem);

 <% items.each do |item| %>
   <%= "var attributes = JSON.parse('#{item.to_json}\');".html_safe %>
   <%= "attributes = _.pick(attributes, 'subject', 'start', 'end');".html_safe %>
   <%= "if(attributes.start) { attributes.start = moment.utc(attributes.start).format('hh:mma'); }".html_safe %>
   <%= "if(attributes.end) { attributes.end = moment.utc(attributes.end).format('hh:mma'); }".html_safe %>

   <%= "addItem(attributes);".html_safe %>
 <% end %>
</script>

Fix issue with `pm` not persisting past errors.
Fix issue with `pm` not persisting past errors.
