In
much the same way as we chose to use the Zend Framework, the key considerations when choosing a
JavaScript library are features, performance, documentation and community. We are going to look at two of
the more popular libraries: Prototype and its cousin Script.aculo.us, and Yahoo??™s YUI.
4.3.1 Prototype and Script.aculo.us
The Prototype library provides a set of functionalities to make Ajax calls easy. It has an emphasis on extending
the JavaScript DOM to make it easier to work with. Prototype also cross browser compatible. The
script.aculo.us library is a higher level library built upon Prototype that concentrates on visual effects such as
drag-and-drop and visual effects. Prototype and script.aculo.us development is tried quite closely to Ruby on
Rails and you see some Ruby/Rails idioms in the prototype function names.
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Let??™s look at how our simple example changes when using prototype. Other than including the prototype.js
file in ajax.html, all the changes are in ajax.js, as shown in listing 4.4.
Listing 4.4: Replacing our JavaScript with prototype for our simple Ajax example
var handleSuccess = function(transport) {
if(transport.
Pages:
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131