//reviews/index.html.erb for 'Load Reviews' link on Show Page
$(function() {
  $("a.load_reviews").on("click", function(e) {   
//Send AJAX HIGH-LEVEL get request
  $.get(this.href).success(function(json) {
    var $ol = $("div.reviews ol")
    $ol.html(" ")
    json.forEach(function(review) {
      $ol.append("<li>" + review + "</li>");
    });
  });
 //Load response into HTML of page
  e.preventDefault();
 });
});

//reviews/index.html.erb for 'More' reviews link on Index Page
$(function () {
  $(".js-more").on('click', function() {
    $(this).hide();
    var id = $(this).data("id");
    $.get("/reviews/" + id + ".json", function(data) {
      var review = data;
      $("#body-" + id).html("Comments: " + '"' + review["content"] + '"');
    });
  });
});

//reviews/show.html.erb for 'Next' review button on Show Page
$(function () {
  $(".js-next").on("click", function() {
    var nextId = parseInt($(".js-next").attr("data-id")) + 1;
    $.get("/reviews/" + nextId + ".json", function(data) {
      var review = data; //rn=text(review["restaurant"]["name"])
      //$(".restaurantName").html('<a href=' + "/reviews/:id" + '>'+text(rn)+'</a>');
      $(".restaurantName").text("Restaurant Name: " + review["restaurant"]["name"]);
      $(".reviewBody").text("Comments: " + '"' + review["content"] + '"');
      $(".reviewCuisines").text("Cuisines:" + review["cuisine"]["name"]);
      $(".reviewRating").text(review["rating"]);
      $(".reviewDateVisited").date(review["date_visited"]);
      $(".reviewUpdatedAt").date(review["updated_at"]);
      $(".userEmail").text(review["user"]["email"]);
// re-set the id to current on the link
      $(".js-next").attr("data-id", review["id"]);
    });
  });
});

@@ -209,18 +209,18 @@
    var $
-o
 l
+i
  = $(%22di
@@ -233,18 +233,18 @@
 ews 
-o
 l
+i
 %22)%0A    $
 ol.h
@@ -239,18 +239,18 @@
 %22)%0A    $
-o
 l
+i
 .html(%22 
@@ -299,10 +299,10 @@
    $
-o
 l
+i
 .app

fix <li> in load_reviews links