Created
January 21, 2012 00:17
-
-
Save don/1650393 to your computer and use it in GitHub Desktop.
Code samples for Sencha Touch Blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.application({ | |
launch: function() { | |
// define our app here | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var store = Ext.create('Ext.data.Store', { | |
storeId: "activityStore", | |
model: "Activity", | |
proxy: { | |
type: 'ajax', | |
url: 'exercise.json' | |
}, | |
autoLoad: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var view = Ext.create("Ext.NavigationView", { | |
fullscreen: true, | |
items: [ | |
{ | |
xtype: 'list', | |
title: 'Activities', | |
itemTpl: '{date:date("m/d/Y")} - {type}', | |
store: store | |
} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var view = Ext.create("Ext.NavigationView", { | |
fullscreen: true, | |
items: [ | |
{ | |
xtype: 'list', | |
title: 'Activities', | |
itemTpl: '{date} - {type}', | |
store: store | |
} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id":3, | |
"date": "12/10/2011", | |
"type": "Walk", | |
"distance": "2.5 miles", | |
"comments": "Shouldn't have taken the dog", | |
"minutes": 45 | |
}, | |
... | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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