PhpRiot
Download This Article
Download this article or the entire “Eight Weeks of Prototype” series with all listings and files.




More information
Browse Articles
Ajax (4), APC (1), CAPTCHA (1), CSS (3), Debugging (1), File Upload (1), Google (3), Google Maps (2), JavaScript (12), JSON (2), MVC (1), MySQL (7), onbeforeunload (1), OOP (1), PHP (28), PhpDoc (1), PostgreSQL (6), Prototype (11), Reflection (1), RFC 1867 (1), Robots (1), Scriptaculous (1), SEO (1), Sessions (1), SimpleXML (1), Smarty (5), SOAP (1), SPL (1), Templates (2), W3C (1), XHTML (1), Zend Framework (1), Zend_Search_Lucene (1)

PhpRiot Newsletter
Your Email Address:

Eight Weeks of Prototype: Week 8, A Complete Prototype Example

Starting the JavaScript Application

The next step is to implement the Application.js file, used to bootstrap the application. That is, it is responsible for instantiating the contact manager JavaScript classes. The technique used here of creating an object in which to hold useful application functions is shoed in the previous article in this series.

Listing 9 shows the code for Application.js, which I assume you store in the /js directory on your web server.

Listing 9 The application JavaScript bootstrap file (Application.js)
var Application = {
 
    startup : function()
    {
        new AddressBook_Creator('creator');
        new AddressBook_Contacts('contacts');
    }
};
 
Event.observe(window, 'load', Application.startup);

Note that if you load the index.html file (from Listing 8) in your web browser now an error will occur since the AddressBook_Creator and AddressBook_Contacts classes have not yet been defined.

In This Article


Tagged in , , ,