< Back
Page 8 of 8
This chapter is from the book
Workshop
The workshop contains a quiz and some exercises to help you check your comprehension and understanding.
Quiz
- What files make up the jQuery Mobile framework?
- True or False: The $(document).ready() function cannot be used on pages that are added to the DOM through AJAX.
- How is the .on() function different from the .bind() function?
- True or False: You can use the .on() function with jQuery 1.6.4.
- True or False: The use of data attributes in HTML has been around since HTML 3.2.
Answers
- The jQuery Mobile framework is made up of a JavaScript file and a CSS style sheet. However, to function, the jQuery framework must be included.
- True. The document is only loaded once per page and will not run on subsequent pages that are inserted into the DOM through AJAX.
- The main difference is that you can use the .on() function to bind events to objects that do not exist on initial page load. This is extremely helpful with binding events to elements that appear through AJAX.
- False. The .on() function was not added to the jQuery framework until version 1.7. Prior to that you could use .delegate() or the .bind() functions for event binding.
- False. The use of data attributes is new to HTML5 and has been added to the specification specifically for easier data manipulation and storage.
Exercises
- Create your own data-attribute and add it to a page. Try using some jQuery scripts to get data from it or as a way to help create a selector for the element.
- Take some of the code from the chapter and add more links and more pages. Experiment with setting up multiple pageinit events for your new pages.
- Try using the .on() function with another event and with an object that is on a separate page. Try binding different events with it. Something as simple as a click event that triggers an alert() function is a good way to get started with understanding how the .on() function works with events.
< Back
Page 8 of 8