PDA

View Full Version : Help with loading dropbox



jpthoma2
9 Oct 2011, 11:43 AM
Hello. I've just started trying to learn Sencha Touch and am stuck. Any help getting over this speedbump would be most appreciated.:-/

I am simply trying to load a dropbox from a store. I'm using the forms example in the download for guidance. It looks right to me, but i'm sure i missed some basic concept. I am trying to use the MVC model.

I've attached my files here: 28584, but also laid out my code below. Please let me know if you need anything else to be able to offer any hints. I'm not looking for you to do this for me, but just to offer some hints on what concept I am missing.

Here's my panel with my form in newssettingsCard.


SamfordNews.views.NewsSettings = Ext.extend(Ext.Panel,{
title:"Set News Source",
iconCls:"settings",
items:
[{
xtype:'fieldset',
title:'Choose favorite Samford news source',
items:
[
{
xtype:'selectfield',
name:'newssource',
label:'News Source',
valueField:'url',
displayField:'unit',
source: "newsURLS"
}
]
}]


});


Ext.reg('newssettingscard',SamfordNews.views.NewsSettings);


Here is my model in newsModel.js.


Ext.regModel('newsModel',{ fields:[
{name:'unit',type:'string'},
{name:'url',type:'string'}
]
});


Here is my test store in sourceStore.js.


var newsURLS = new Ext.data.JsonStore({
data : [
{ unit : 'Samford University', url : 'http://www.samford.edu'},
{ unit : 'School of Law', url : 'http://cumberland.samford.edu'},
{ unit : 'School of Nursing', url: 'http://nursing.samford.edu'},
{ unit : 'School of the Arts', url: 'http://arts.samford.edu'}
],
model : 'newsModel',
autoLoad : true,
autoDestroy : true
});


Here is my index.

<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../resources/css/sencha-touch.css" type="text/css">

<title>Hello World</title>
<script type="text/javascript" src="../../sencha-touch.js"></script>
<!-- index, models, stores, views, controllers (in that order!) -->
<script type="text/javascript" src="src/index.js"></script>
<script type="text/javascript" src="src/models/newsModel.js"></script>
<script type="text/javascript" src="src/stores/sourceStore.js"></script>
<script type="text/javascript" src="src/views/ViewPort.js"></script>
<script type="text/javascript" src="src/views/newslistCard.js"></script>
<script type="text/javascript" src="src/views/newssettingsCard.js"></script>
</head>
<body></body>
</html>

My ultimate goal is to make an app that will subscribe a RSS feed to a list. This news setting card will allow the user to set a default "favorite" RSS feed.

bassjobsen
10 Oct 2011, 6:10 AM
use store: newsURLS in stead of soure : "newsURLS"


Ext.setup( {
onReady: function() {

Ext.regModel('newsModel',{ fields:[
{name:'unit',type:'string'},
{name:'url',type:'string'}
]
});


var newsURLS = new Ext.data.JsonStore({
data : [
{ unit : 'Samford University', url : 'http://www.samford.edu'},
{ unit : 'School of Law', url : 'http://cumberland.samford.edu'},
{ unit : 'School of Nursing', url: 'http://nursing.samford.edu'},
{ unit : 'School of the Arts', url: 'http://arts.samford.edu'}
],
model : 'newsModel',
autoLoad : true,
autoDestroy : true
});

var newsSetting = new Ext.Panel({
title:"Set News Source",
iconCls:"settings",
items:
[{
xtype:'form',
items:
[
{xtype:'fieldset',title:'Choose favorite Samford news source'},
{
xtype:'selectfield',
name:'newssource',
label:'News Source',
valueField:'url',
displayField:'unit',
store: newsURLS
}
]
}]


});