Skip to content

Instantly share code, notes, and snippets.

@don
Created January 21, 2012 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save don/1650393 to your computer and use it in GitHub Desktop.
Save don/1650393 to your computer and use it in GitHub Desktop.
Code samples for Sencha Touch Blog post
Ext.application({
launch: function() {
// define our app here
}
});
var addNewRow = function() {
// future versions should display a form for adding a record
var fakeRecord = Ext.create('Activity', {
date: new Date(),
type: 'Walk',
distance: '2 miles',
minutes: 28,
comments: 'Auto generated record.'
});
store.add(fakeRecord);
};
view.getNavigationBar().add({
xtype: 'button',
text: 'Add',
align: 'right',
handler: addNewRow
});
Ext.define("Activity", {
extend: "Ext.data.Model",
fields: [
{name: 'id', type: 'int'},
{name: 'date', type: 'date'},
{name: 'type', type: 'string'},
{name: 'distance', type: 'string'},
{name: 'minutes', type: 'int'},
{name: 'comments', type: 'string'}
]
});
var store = Ext.create('Ext.data.Store', {
storeId: "activityStore",
model: "Activity",
proxy: {
type: 'ajax',
url: 'exercise.json'
},
autoLoad: true
});
var view = Ext.create("Ext.NavigationView", {
fullscreen: true,
items: [
{
xtype: 'list',
title: 'Activities',
itemTpl: '{date:date("m/d/Y")} - {type}',
store: store
}
]
});
var view = Ext.create("Ext.NavigationView", {
fullscreen: true,
items: [
{
xtype: 'list',
title: 'Activities',
itemTpl: '{date} - {type}',
store: store
}
]
});
[
{
"id":3,
"date": "12/10/2011",
"type": "Walk",
"distance": "2.5 miles",
"comments": "Shouldn't have taken the dog",
"minutes": 45
},
...
]
<!DOCTYPE html>
<html>
<head>
<title>Exercise</title>
<link rel="stylesheet" href="touch/resources/css/sencha-touch.css" type="text/css">
<script type="text/javascript" src="touch/sencha-touch-all.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment