-
Notifications
You must be signed in to change notification settings - Fork 54
Bryan Reese #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Bryan Reese #35
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ $.ajax({ | |
| }); | ||
|
|
||
|
|
||
|
|
||
| function formData(e){ | ||
| e.preventDefault(); | ||
| var formData = $(this).serialize(); | ||
|
|
@@ -18,19 +17,16 @@ $.ajax({ | |
| } | ||
|
|
||
| // form submission event handler | ||
| $('.form-horizontal').on('submit', formData) | ||
|
|
||
|
|
||
|
|
||
| $('.form-horizontal').on('submit', formData); | ||
| $('#gymDisplay').on("click", ".deleteBtn", handleDeleteBjj); | ||
| }); | ||
|
|
||
|
|
||
|
|
||
| // loop through data and render to html | ||
| function renderMultipleReviews(reviews) { | ||
|
|
||
| console.log(reviews); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation 😭 |
||
| reviews.forEach(function(review) { | ||
| console.log(review) | ||
| renderBjj(review); | ||
| }); | ||
|
|
||
|
|
@@ -42,7 +38,7 @@ function renderBjj(bjj) { | |
|
|
||
| var bjjHtml = (` | ||
|
|
||
| <div class="container forms"> | ||
| <div class="container forms" data-bjj='${bjj._id}'> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be indented to reflect HTML structure. |
||
| <div class="row"> | ||
| <div class="col-sm-12"> | ||
| <div class="card" style="width: 75%;"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. manually setting width is so sad! could add another class so you can still use class-based styling for these cards. |
||
|
|
@@ -56,6 +52,7 @@ function renderBjj(bjj) { | |
| <li class="list-group-item"><span class="desc">Review:</span> ${bjj.reviews}</li> | ||
|
|
||
| </ul> | ||
| <button class="deleteBtn btn-danger" type="click">Remove review</button> | ||
| </div> | ||
| </div> | ||
|
|
||
|
|
@@ -72,3 +69,14 @@ function renderBjj(bjj) { | |
|
|
||
|
|
||
|
|
||
| function handleDeleteBjj(e) { | ||
| console.log('delete-song clicked!'); | ||
| var currentBjjId = $(this).closest('.forms').attr('data-bjj'); // "5665ff1678209c64e51b4e7b" | ||
| var currentBjjElem =$(this).closest('.card'); | ||
| console.log(currentBjjId); | ||
| $.ajax({ | ||
| method:"DELETE", | ||
| url: '/api/bjj/'+currentBjjId, | ||
| success: currentBjjElem.remove() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This removes that element immediately, not as a callback! It'll remove from the page whether or not the API call is successful. It should instead be: success: function() {
currentBjjElem.remove();
} |
||
| }) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,6 @@ body { | |
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just doing what is needed. |
||
| .forms{ | ||
| margin:75px; | ||
|
|
||
|
|
||
| } | ||
|
|
||
| .card-img-top { | ||
|
|
@@ -21,10 +19,10 @@ body { | |
| background-color:black; | ||
| color:white; | ||
| } | ||
|
|
||
| .list-group-flush { | ||
| color:black; | ||
| font-weight:bold; | ||
|
|
||
| } | ||
|
|
||
| .desc { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short and sweet, works.