goTo(), for handling the close-scrollopen
(for a question click) and scroll-open (for a reference click) interactions, respectively.
You??™ll fill in the logic for those methods in a moment. Keep in mind that the links won??™t be
functional until you do.
You??™re also starting to make use of some of the properties of the FAQ object. The first, as
you might have noticed, is FAQ.open_items. Before you execute any action in the event handler,
you test to see whether the id referenced by the clicked anchor is already in that array
(using Prototype??™s Array.indexOf()). When you get to writing the FAQ.open() method, you??™ll
set it to add the id of the newly opened answer to FAQ.open_items.
This brings you to the second property used here: FAQ.to_open. This property enables you
to track the id of the element you??™re opening, so you don??™t have to keep passing it as an argument
from method to method.
Refreshing the page at this point gives you a trace of the events taking place as you click
each question link. Obviously, you haven??™t written the code to actually open the answers back
up, but the clicks are triggering the script to look for the correct id, as shown in Figure 8-6.
Figure 8-6. A trace of some question clicks
CHAPTER 8 n CASE STUDY: FAQ FACELIFT 180
Opening Up
With the stage set by FAQ.initialize(), you can begin to work on the animation for opening
and closing the dd elements.
Pages:
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255