Home > Articles > Programming > Ajax

  • Print
  • + Share This
This chapter is from the book

Workshop

The workshop contains a quiz and some exercises to help you check your comprehension and understanding.

Quiz

  1. What files make up the jQuery Mobile framework?
  2. True or False: The $(document).ready() function cannot be used on pages that are added to the DOM through AJAX.
  3. How is the .on() function different from the .bind() function?
  4. True or False: You can use the .on() function with jQuery 1.6.4.
  5. True or False: The use of data attributes in HTML has been around since HTML 3.2.

Answers

  1. 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.
  2. True. The document is only loaded once per page and will not run on subsequent pages that are inserted into the DOM through AJAX.
  3. 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.
  4. 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.
  5. 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

  1. 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.
  2. 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.
  3. 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.
  • + Share This
  • 🔖 Save To Your Account