SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 242 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

This determination can easily be made by
simply checking to see whether the link??™s parentNode is a dt and then triggering the
appropriate FAQ method.
initialize: function(){
trace( 'initialize()' );
// Collect the DLs & loop
$$( 'dl.faq' ).each( function( dl ){
...cut...
// Loop through the ANCHORs
$A( dl.getElementsByTagName( 'a' ) ).each( function( a ){
var href = a.getAttribute( 'href' );
/* Drop out if the link is not an in-page ANCHOR
or if it's TARGET cannot be found */
if( !href.match( /#/ )||
!$( href.replace( /.*?#(.*)/, '' ) ) ) return;
// set the event handler
Event.observe( a, 'click', function( e ){
var el = Event.element( e );
var id = el.getAttribute( 'href' ).replace( /.*?#/, '' );
trace( 'looking for ' + id );
CHAPTER 8 n CASE STUDY: FAQ FACELIFT 179
// check to see if this link is already open
if( this.open_items.indexOf( id ) == -1 ){
this.to_open = id;
// See if the ANCHOR is inside a DT
if( el.parentNode.nodeName.toUpperCase() == 'DT' ){
/* If yes, we need to set the action to close
any open FAQs and then go */
this.closeAndGo();
} else {
// Otherwise we need to just go to the chosen FAQ
this.goTo();
}
}
return false;
}.bind( this ), false );
}.bind( this ) ); // End ANCHOR loop
} // End DL loop
},
Before you move on, let??™s talk about where things are wiring into one another. You??™re
tying into two methods, FAQ.closeAndGo() and FAQ.


Pages:
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6