-
Notifications
You must be signed in to change notification settings - Fork 3
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
Edit and delete jobs asynchronously #6
Merged
Merged
Conversation
This file contains 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
- Add form to job partial for sending delete request - New utility CSS class for floating right
- Clicking delete will send AJAX DELETE request to /jobs - Show completed requirements on README
That main.js file was getting much too large. Time to split it into smaller scripts that manage jobs and skills, respectively.
When a user clicks the "edit" button next to a job, an edit form will show up to allow them to edit the job information. This is accomplished by rendering the edit forms in the page but ensuring that they are hidden by default. This way, the JS linked to the edit button just hides the job information and shows the form. Currently not asynchronous.
- Editing jobs now sends an AJAX request and will update the DOM with the updated job data - Modified the event listener on the "edit" button to use [event delegation](http://learn.jquery.com/events/event-delegation/) so that it will still function on elements added after the initial page load - Server route /jobs/edit responds to async requests with the job partial HTML
Makes more sense for the job info and the edit form to both be inside the same <li> tag, since they will never be displayed at the same time and thus act like a single list item. This also makes it easier to associate the form with its corresponding job info element from the JavaScript.
Because the page is updating so frequently, it is better to use delegation to ensure that events on newly created elements will trigger the appropriate functions.
Wasn't returning the edit job form along with the job itself, so newly created jobs weren't able to be edited.
- Make naming more conventional - Remove smaller functions - Standardize format of functions
If you want to see what JavaScript is doing, simply open your browser console. As you click around to create, edit, and delete jobs, logging information will render to the JavaScript console.
tannerwelsh
added a commit
that referenced
this pull request
Nov 1, 2014
Edit and delete jobs asynchronously
👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch solves the requirements for release 1.2.0:
In addition, it adds console logging to the jobs.js functions. If you want to see what JavaScript is doing, simply open your browser console. As you click around to create, edit, and delete jobs, logging information will render to the JavaScript console.