Coder Social home page Coder Social logo

express-personal-api's People

Contributors

justincastilla avatar nathanallen avatar tbduong avatar tgaff avatar

Watchers

 avatar  avatar

express-personal-api's Issues

Create Entry Button is buggy

Several little issues with my "Create Entry" button:

  1. Button is able to post/create , but is appending to the middle of the page on Heroku and end of the page in locally. Post is showing all data entered in the form, but won't show new "summary" and new "image" url.

  2. "Create Entry" button works only after I refresh the page. Wondering what jQuery command is needed to make the buttons (delete button also) take effect immediately. Works in Postman.

  $('#newTravelForm').on('submit', function(e) {
    e.preventDefault();
    $.ajax({
      method: 'POST',
      url: '/api/travels',
      data: $(this).serialize(),
      success: newTravelSuccess,
      error: newTravelError
    });
  });
<div id="target">
      <script id="travels-template" type="text/x-handlebars-template">
        <table class="table">
          <tbody>
            <tr id=header>
              <th>City</th>
              <th>State</th>
              <th>Country</th>
              <th>Year Visited</th>
              <th>Summary</th>
              <th>Image Link</th>
            </tr>
            {{#each travels}}
            <tr>
              <td>{{city}}</td>
              <td>{{state}}</td>
              <td>{{country}}</td>
              <td>{{year_visited}}</td>
              <td>{{summary}}</td>
              <td><img class="img-responsive" src="{{image}}"></td>
              <td>
                <button type="button" name="button" class="delete btn btn-danger center" data-id={{_id}}>Delete Entry</button>
              </tr>
            </tr>
            {{/each}}
          </tbody>
        </table>
      </script>
    </div>```

Delete button doesn't work-Halppp!

Class and information matches up within html and js! Thinking I might have no drilled down enough for the id? And/or might have overlooked some syntax! DELETE method works with Postman, so not sure what the issue is. Here's the js and html.

 $travelsList.on('click', '.delete', function() {
    $.ajax({
      method: 'DELETE',
      url: '/api/travels/'+$(this).attr('data-id'),
      success: deleteTravelSuccess,
      error: deleteTravelError
    });
  });
<div id="target">
      <script id="travels-template" type="text/x-handlebars-template">
        <table class="table">
          <tbody>
            <tr id=header>
              <th>City</th>
              <th>State</th>
              <th>Country</th>
              <th>Year Visited</th>
              <th>Summary</th>
              <th>Image Link</th>
            </tr>
            {{#each travels}}
            <tr>
              <td>{{city}}</td>
              <td>{{state}}</td>
              <td>{{country}}</td>
              <td>{{year_visited}}</td>
              <td>{{summary}}</td>
              <td><img class="img-responsive" src="{{image}}"></td>
              <td>
                **<button type="button" name="button" class="delete btn btn-danger center" data-id={{_id}}>Delete Entry</button>**
              </tr>
            </tr>
            {{/each}}
          </tbody>
        </table>
      </script>
    </div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.