Last active
August 16, 2016 22:58
-
-
Save bootcoder/4c5650b86c83eebea4058d57243dc24c to your computer and use it in GitHub Desktop.
horse-ajax-pseudo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Relase 1 Psuedocode | |
- Make <form> and <a> tags functional | |
- Use horses/new as a partial that will be rendered with AJAX after user clicks on the appropriate link | |
- Create a new function to hold event listener for the #new-horse-link | |
- Confirm listener functions | |
- Use AJAX to intercept the HTTP request | |
- hide the #new-horse-link | |
- Modify controller @ route '/horses/new' to respond to xhr | |
- Confirm getting to route I think I need | |
- Controller will return compiled erb with an ID = #horse-form | |
- Make sure to specify "layout: false" when rendering partial | |
- Make sure erb has all variables it needs | |
Release 2 Pseudocode | |
- Create a new function to hold event listener for the #horse-form submission | |
- listener needs to be dynamic | |
- Confirm listener functions | |
- Use .preventDefault() to intercept the HTTP request | |
- Use AJAX to send form data to ruby server | |
- get info needed for valid AJAX call | |
- action | |
- method | |
- form data | |
- Build AJAX options and send off | |
- Go to controller land | |
- modify route post '/horses' to be xhr compliant | |
- create the new horse in the database with params received from AJAX | |
- Return partial with horse info from newly created horse | |
- Back in AJAX land | |
- Confirm .done gives back the data I expected | |
- Append the horse html from controller to the div with ID = #horse-list | |
- Remove horse form from page | |
- re-show the #new-horse-link | |
Release 3 Pseudocode | |
- Use AJAX to display horse's info with a partial | |
- Create a new function to hold event listener for <h3> or <a> tag, IDK depends on issues that pop up | |
- before AJAX, check for horse deets | |
- if deets, remove deets | |
- else, proceed to AJAX | |
- assign that = this for current context of clicked element | |
- AJAX goes to /horses/:id route | |
- need to get horse ID from DOM for url | |
- Off to Controller land | |
- find horse based on ID passed in params from AJAX | |
- create/format partial view for horse details | |
- Return a partial with horse details | |
- use jQuery to append horse details to 'that' element | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment