The final step of the third task is to centralize the jQuery document.ready events. Currently each module has a ready event. Instead, the three events can be combined into a single app.js file.
(Asian intro music)…- Let's come back to our Read Me.…Let's check and see.…So item number four suggested that we do…exactly what I just talked to you about.…There's one last item.…This, hopefully, is a much easier thing to get…your brain around.…But there's one last item to task three.…It says, "Refactor so there is only…one jQuery "document ready" event."…And it should call the init method…of each of the three modules.…
Suggests here that we want to add a new file.…So I'm going to create a new file.…I'm going to call it, for my purposes, app.js.…It should have a document ready event in it.…Now inside of this code, I want to…call all three of the initialization methods…for all of my modules.…So I have header.init, and I do need the parentheses here…because I'm calling the functions.…
What's the next one I need?…- [Men] Carousel.…Carousel.init.…- [Man] And then details.…- And then details.init.…That wasn't that hard, right?…The last step then is to go back to those other modules…and take out that superfluous document ready…
Note: This course was created on 03/29/2016 by Frontend Masters. We are pleased to host this content in our library.
- Carousels, panes, and modules
- Middle-end architecture
- Secure phrase generator
- Routing functions
- Calling the API
- Rendering on the page
- Shared data validation
Skill Level Intermediate
2. Organizing Code
5. Adding a Shared Module
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.