Book Image

Ext JS Application Development Blueprints

Book Image

Ext JS Application Development Blueprints

Overview of this book

Table of Contents (18 chapters)
Ext JS Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Code, code, and more code


It's time to get our hands dirty and put fingers to keyboards. As always, we generated a new base application using Sencha Cmd and will use the resulting "main" view as a starting point for our user interface. First though, let's flesh out the data layer that we designed earlier:

// app/model/BaseModel.js
Ext.define('Alcohology.model.BaseModel', {
    extend: 'Ext.data.Model',

    schema: {
        namespace: 'Alcohology.model',
        urlPrefix: 'http://localhost:3000',
        proxy: {
            type: 'rest',
            url: '{prefix}/{entityName:uncapitalize}'
        }
    }
});

We've used a base model in previous chapters because it gives us a good way of centralizing proxy configuration. The models that inherit from it are all straightforward, as shown in the following code:

// app/model/CartItem.js
Ext.define('Alcohology.model.CartItem', {
    extend: 'Alcohology.model.BaseModel',
    fields: [
        { name: 'productId' },
        { name: 'productName...