anchor.diff:    <small><%= link_to "Edit income", edit_plan_path %></small>
   </div>
   <!-- Button trigger modal -->
  -<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">
  +<button type="button" class="btn btn-default js-previous" data-toggle="modal" data-target="#myModal" data-id="<%= @plan.id %>">
     Previous plans
   </button>
   
  
positive.code:     <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">Modal title</h4>
        </div>
        <div class="modal-body">
          ...
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary">Previous</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
  
negative.code:     <% end %>
    </div>
  </div>
  
  
  <script type="text/javascript" charset="utf-8">
  $(function () {
    $(".js-previous").on("click", function() {
      var nextId = parseInt($(".js-previous").attr("data-id")) - 1;
      $.get("/plans/" + nextId + ".json", function(data) {
        var date = new Date(data["date"]);
        var month = [];
        month[0] = "January";
        month[1] = "February";
        month[2] = "March";
        month[3] = "April";
        month[4] = "May";
        month[5] = "June";
        month[6] = "July";
        month[7] = "August";
        month[8] = "September";
        month[9] = "October";
        month[10] = "November";
        month[11] = "December";
        $(".modal-title").text(`In ${month[date.getMonth()]} you budgeted...`);
  
        var purchases = data["purchases"];
        var purchasesString = "";
        $.each(purchases, function(i, purchase) {
          purchasesString += `<p data-paymentid="${purchase["id"]}">` + "$" + `${purchase["price"]} ` + "for " + `${purchase["item"]} ` + "</p>";
        });
        $(".modal-body").html(purchasesString);
        // re-set the id to current on the link
        $(".js-previous").attr("data-id", data["id"]);
      });
    });
  });
  </script>
  