danvega
13 Jul 2010, 6:39 PM
I tried taking the twitter example and simplifying it a little so that I could better understand how it works. I moved everything into a basic application. The only problem is the following code just won't work like this and I can't figure out what I am doing wrong. Every time I run the following (or some variation) I get the error
"this.model is undefined
[Break on this error] var fields = this.model.prototype.fields.items, ext-to...ebug.js (line 11799"
Ext.setup({
icon: 'assets/images/icon.png',
glossOnIcon:true,
onReady: function(){
var titleBar = new Ext.Toolbar({
dock: 'top',
ui: 'light'
});
Ext.regModel('Tweet', {
fields: [
{name: 'id',type: 'int'},
{name: 'profile_image_url',type: 'string'},
{name: 'from_user',type: 'string'},
{name: 'text',type: 'string'}
]
});
var timeline = new Ext.List({
title:'Twitter',
iconCls:'time',
cls: 'timeline',
scroll: false,
tpl: [
'<tpl for=".">',
'<div class="tweet">',
'<img src="{profile_image_url}" />',
'<div class="x-tweetanchor"></div>',
'<div class="tweet-bubble">',
'<div class="tweet-content">',
'<h2>{from_user}</h2>',
'<p>{text}</p><strong></strong>',
'<span class="posted">{created_at}</span>',
'</div>',
'</div>',
'</div>',
'</div>',
'</tpl>'
].join(''),
itemSelector: 'div.tweet',
emptyText : '<p style="padding: 10px">No tweets found matching that search</p>',
store: new Ext.data.Store({
autoLoad: true,
model: "Tweet",
proxy: new Ext.data.ScriptTagProxy({
url: 'http://search.twitter.com/search.json',
extraParams: {
q: 'Cleveland',
rpp: 50,
suppress_response_codes: true
}
})
})
});
var tp = new Ext.TabPanel({
fullscreen:true,
dockedItems:[titleBar],
ui:'light',
animation:{type:'slide',cover:true},
tabBar: {
centered:true,
dock:'bottom',
layout: {pack:'center'}
},
defaults:{
scroll:'vertical'
},
listeners: {
afterlayout : function() {
titleBar.setTitle(this.layout.activeItem.title);
},
cardswitch: function(card) {
titleBar.setTitle(card.title);
}
},
items:[timeline]
});
}
});
"this.model is undefined
[Break on this error] var fields = this.model.prototype.fields.items, ext-to...ebug.js (line 11799"
Ext.setup({
icon: 'assets/images/icon.png',
glossOnIcon:true,
onReady: function(){
var titleBar = new Ext.Toolbar({
dock: 'top',
ui: 'light'
});
Ext.regModel('Tweet', {
fields: [
{name: 'id',type: 'int'},
{name: 'profile_image_url',type: 'string'},
{name: 'from_user',type: 'string'},
{name: 'text',type: 'string'}
]
});
var timeline = new Ext.List({
title:'Twitter',
iconCls:'time',
cls: 'timeline',
scroll: false,
tpl: [
'<tpl for=".">',
'<div class="tweet">',
'<img src="{profile_image_url}" />',
'<div class="x-tweetanchor"></div>',
'<div class="tweet-bubble">',
'<div class="tweet-content">',
'<h2>{from_user}</h2>',
'<p>{text}</p><strong></strong>',
'<span class="posted">{created_at}</span>',
'</div>',
'</div>',
'</div>',
'</div>',
'</tpl>'
].join(''),
itemSelector: 'div.tweet',
emptyText : '<p style="padding: 10px">No tweets found matching that search</p>',
store: new Ext.data.Store({
autoLoad: true,
model: "Tweet",
proxy: new Ext.data.ScriptTagProxy({
url: 'http://search.twitter.com/search.json',
extraParams: {
q: 'Cleveland',
rpp: 50,
suppress_response_codes: true
}
})
})
});
var tp = new Ext.TabPanel({
fullscreen:true,
dockedItems:[titleBar],
ui:'light',
animation:{type:'slide',cover:true},
tabBar: {
centered:true,
dock:'bottom',
layout: {pack:'center'}
},
defaults:{
scroll:'vertical'
},
listeners: {
afterlayout : function() {
titleBar.setTitle(this.layout.activeItem.title);
},
cardswitch: function(card) {
titleBar.setTitle(card.title);
}
},
items:[timeline]
});
}
});