Online Book Reader

Home Category

AJAX In Action [297]

By Root 4036 0
the language. The second was to point out several traps for the unwary, in which thinking in an OO style may result in suboptimal or even dangerous code. We’ve looked at JavaScript’s support for objects and at the similarities between the Object and Array classes. We’ve seen several ways of instantiating JavaScript objects, using JSON, constructor functions, and the prototype concept. Along the way, we’ve discussed how to tackle OO concepts such as inheritance and interfaces in JavaScript, in ways that work with rather than against the language. In our exploration of JavaScript Function objects, we saw how functions can exist independently of any object to which they are assigned and even be borrowed or swapped between objects. We used this knowledge to get a better understanding of the JavaScript event model. Finally, we looked at closures and saw how some common programming idioms can create closures unintentionally, potentially resulting in memory leaks. Compared to Java or C#, JavaScript offers a great deal of flexibility and scope for developing personal styles and approaches to the language. This can be liberating for the individual programmer, provided that you know what you are doing. It can also present problems when working in teams, but these problems can be alleviated by shared coding conventions or house styles.

JavaScript can be a very enjoyable language to work with, once you understand what makes it tick. If you’re coming to Ajax from a structured OO background, we hope that this chapter has helped you to cross the gap. B.5 Resources

There are very few books on JavaScript the language, as opposed to web browser programming. David Flanagan’s JavaScript: The Definitive Guide (O’Reilly, 2001) is the definitive work. It’s a bit old, but a new version is due out next year. A more Licensed to jonathan zheng

618

APPENDIX B

JavaScript for object-oriented programmers

recent book, Nicholas Zakas’s Professional JavaScript for Web Developers (Wrox, 2004) offers a good language overview, too, and covers some more recent developments in the language. On the Web, Doug Crockford discusses object-oriented approaches to JavaScript, such as creating private members for classes (www.crockford.com/javascript/private.html) and inheritance (www.crockford.com/javascript/private.html). Peter-Paul Koch’s Quirksmode site (http://quirksmode.org) also discusses many of the finer points of the language. Jim Ley’s discussion of closures in JavaScript can be found at http://jibbering.com/faq/faq_notes/closures.html.

Mike Foster’s x library can be found at www.cross-browser.com.

Licensed to jonathan zheng

Ajax frameworks

and libraries

619

Licensed to jonathan zheng

620

APPENDIX C

Ajax frameworks and libraries

The last year has seen a rapid proliferation of Ajax and JavaScript frameworks, from small cross-browser wrapper utilities to complete end-to-end client and server solutions. In this appendix, we attempt to take a snapshot of the current range of offerings, with apologies to any that we’ve omitted.

We, the authors of this book, haven’t personally used all of these frameworks and toolkits in a production setting, and in many cases we’ve based our descriptions on the author or vendor’s own claims for the toolkit. If you’re reading this a year after publication, many of the descriptions will be wildly inaccurate or out of date, and many of the frameworks may have been abandoned or absorbed into other projects. The current state of play is unstable, in our opinions, and we would expect a few successful frameworks to predominate over the next 12 months.

So here, without any further ado, is our roundup of Ajax frameworks that you might encounter in the wild. We haven’t attempted to categorize them beyond listing them alphabetically. Happy coding!

Accesskey Underlining Library

Open source

www.gerv.net/software/aul/

Adds accesskey underlining to pages without requiring tags in the source. Tag items with the accesskey attribute and JavaScript will create

®Online Book Reader