ssdesign
8 Jul 2010, 10:35 PM
Hi,
This might be a stupid one, but this is my first try at localstorage.
I tried to put together something by reading the Solitaire game as well as the API.
When I try to run this code, it says:
Uncaught TypeError: Cannot call mothod 'index' of undefined.
Ext.ns('iFonts');
Ext.onReady(function() {
iFonts.Index.index();
});
Ext.regModel('Font', {
fields: [
{name: 'name', type: 'string'},
{name: 'age', type: 'int'},
{name: 'phone', type: 'string'},
{name: 'alive', type: 'boolean', defaultValue: true}
],
changeName: function() {
var oldName = this.get('name'),
newName = oldName + " The Great";
this.set('name', newName);
}
});
iFonts.Index = new Ext.Controller({
localStorageKey: 'iFontId',
index : function() {
// Create Database
this.fontStore = new Ext.data.Store({
proxy: new Ext.data.LocalStorageProxy({
id: 'iFont-Font'
}),
model: 'Font',
autoLoad: false
});
// Read Database
this.fontStore.read({
scope: this,
callback: function(records, operation, successful) {
if (records.length == 0) {
alert ('No Data');
} else {
}
}
});
}
});
This might be a stupid one, but this is my first try at localstorage.
I tried to put together something by reading the Solitaire game as well as the API.
When I try to run this code, it says:
Uncaught TypeError: Cannot call mothod 'index' of undefined.
Ext.ns('iFonts');
Ext.onReady(function() {
iFonts.Index.index();
});
Ext.regModel('Font', {
fields: [
{name: 'name', type: 'string'},
{name: 'age', type: 'int'},
{name: 'phone', type: 'string'},
{name: 'alive', type: 'boolean', defaultValue: true}
],
changeName: function() {
var oldName = this.get('name'),
newName = oldName + " The Great";
this.set('name', newName);
}
});
iFonts.Index = new Ext.Controller({
localStorageKey: 'iFontId',
index : function() {
// Create Database
this.fontStore = new Ext.data.Store({
proxy: new Ext.data.LocalStorageProxy({
id: 'iFont-Font'
}),
model: 'Font',
autoLoad: false
});
// Read Database
this.fontStore.read({
scope: this,
callback: function(records, operation, successful) {
if (records.length == 0) {
alert ('No Data');
} else {
}
}
});
}
});