Slide 23
Slide 23 text
Sencha Touch Workshop
Defining a LocalStorageProxy
• The following example illustrates defining a model for
contacts that references a localstorage area named
localContacts
Ext.define('Sample.model.Contact',
{
extend: 'Ext.data.Model',
fields: [
{name: 'lname', type: 'string', allowBlank: false },
{name: 'fname', type: 'string', allowBlank: false },
{name: 'email', type: 'string', allowBlank: false}
],
validations: [
{type: 'presence', field: 'fname'},
{type: 'presence',field: 'lname'},
{type: 'format', field: 'email', matcher: /^[a-zA-
Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/}
],
proxy: {
type: 'localstorage',
id: 'localContacts'
}
}
)
Wednesday, June 5, 13