$(document).ready(function() {
  submitForm();
  clickToEdit();
});

function submitForm() {
  $("#new_element").on("submit", function(event) {
    event.preventDefault();
    var folioId = $("#id").val();
    console.log(folioId);
    var data = $(this).serialize();
    console.log(this);
    elm_id = "#" + id;
    console.log(elm_id);
    console.log($(elm_id).hasClass("editing"));
    if ($(elm_id).hasClass("editing")) {
      console.log("true");
      update(id);
    } else {
      post(id, data);
    }
    // ^this code doesn't work yet.  Why?
  });
}

function post(id, data) {

  $.ajax({
    dataType: "json",
    method: "POST",
    url: "/folios/" + id + "/elements",
    data: data
  }).done(function(responseData) {
    var element = new Element(responseData);
    var elementView = new ElementView();
    var html = elementView.compile(element);
    elementView.render(html);
    folioView.toggleSidebar();
  });
}

@@ -203,34 +203,9 @@
 ();%0A
-    console.log(folioId);
 %0A
+
     
@@ -240,34 +240,15 @@
 ();%0A
-    console.log(this);
 %0A   
+ //
  elm
@@ -263,88 +263,18 @@
 %22 + 
-id;%0A    console.log(elm_id);%0A    console.log($(elm_id).hasClass(%22editing%22));%0A   
+;%0A%0A%0A    //
  if 
@@ -310,16 +310,19 @@
 )) %7B%0A   
+ //
    conso
@@ -340,16 +340,19 @@
 e%22);%0A   
+ //
    updat
@@ -361,16 +361,19 @@
 id);%0A   
+ //
  %7D else 
@@ -379,23 +379,27 @@
  %7B%0A     
- 
 post(
-i
+folioI
 d, data)
@@ -403,16 +403,19 @@
 ta);%0A   
+ //
  %7D%0A    /
@@ -474,17 +474,22 @@
 on post(
-i
+folioI
 d, data)
@@ -567,17 +567,22 @@
 ios/%22 + 
-i
+folioI
 d + %22/el

Update submit js