The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

abdallah1986 (1) [Avatar] Offline
#1
Greeting every body

i was trying to take a sencha code offline following this tutorial
http://www.sencha.com/learn/taking-sencha-touch-apps-offline/
but this tutorial is most relevant to sencha 1.x and i am starting to use sencha 2.x so i tried to follow this tutorial to solve the problem
http://www.sencha.com/learn/upgrading-to-sencha-touch-2-pr2/

but i still have some issues because i am just starting with sencha touch and i will be thankfull if someone could help me with this.

This is my code:

Ext.define("Photo", {
extend: "Ext.data.Model",
config: {
fields: [
{name:'id'},
{name:'farm'},
{name:'owner'},
{name:'secret'},
{name:'server'},
{name:'title'},
{name:'url'},
],
setUrl: function() {
var url = "http://farm" + this.get('farm') +
".static.flickr.com/" + this.get('server') +
"/" + this.get('id') + "_" + this.get('secret') + "_s.jpg";
var script = document.createElement("script");
script.setAttribute("src",
"http://src.sencha.io/data.helloWorld.setPhotoUrl-" + this.getId() +
"/" + url
);
script.setAttribute("type","text/javascript");
document.body.appendChild(script);
}
}
});
Ext.Application({
name: "helloworld",
setPhotoUrl: function (id, dataUrl) {
var photo = this.offlineStore.getById(id);
photo.set('url', dataUrl);
this.offlineStore.sync();
},


onlineStore: Ext.define("onlineStore", {
extend: "Ext.data.Store",
requires:"Ext.data.proxy.OnlineStorage",
config: {
model: 'Photo',
proxy: {
type: 'scripttag',
url: 'http://query.yahooapis.com/v1/public/yql?format=json&q=' +
escape(
'select * from flickr.photos.search where text="hello" limit 10'
),
reader: Ext.define("reader", {
extend: "Ext.data.JsonReader",
root: 'query.results.photo'
}),
timeout: 2000,
listeners: {
exception:function () {
console.log("I think we are offline");
helloWorld.gallery.bindStore(helloWorld.offlineStore);
helloWorld.offlineStore.load();
}
}
}
}
}),
offlineStore: Ext.define("offlineStore", {
extend: "Ext.data.Store",
requires:"Ext.data.proxy.LocalStorage",
config: {
model: 'Photo',
proxy: {
type: 'localstorage',
id: 'helloworld'
}
}
}),
launch: function() {
this.tabs = new Ext.TabPanel({
fullscreen: true,
dockedItems: [{xtype:'toolbar', title:'Hello World'}],
tabBar: {
ui: 'light',
layout: {
pack: 'center'
}
},
items: [
{cls:'hello', title:'Hello'},
{cls:'world', title:'World'},
{
cls: 'gallery',
title: 'Gallery',
xtype: 'list',
store: null,
itemTpl:'{title}'
}
]
});
this.gallery = this.tabs.items.getAt(2);

this.onlineStore.addListener('load', function () {
console.log("I think we are online");
helloWorld.offlineStore.proxy.clear();
this.each(function (record) {
var photo = helloWorld.offlineStore.add(record.data)[0];
photo.setUrl();
});
helloWorld.offlineStore.sync();
helloWorld.gallery.bindStore(helloWorld.offlineStore);
});
this.onlineStore.load();
}

});


chrome developer tools console shows me those error:

Uncaught TypeError: Object #<Object> has no method 'Application' app.js:27
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/offline/sdk/src/data/proxy/OnlineStorage.js?_dc=1338287734798
Uncaught Error: [Ext.Loader] Failed loading 'http://localhost/offline/sdk/src/data/proxy/OnlineStorage.js', please verify that the file exists sencha-touch.js:8017

i have tried to solve this but i didn't find what really is the mistake.

is some help available please? thank you
mitchellsimoens (12) [Avatar] Offline
#2
Re: problem taking sencha app offline with sencha 2
@abdallah1986 This forum is for the book and your question is not about the book. You may find more help at http://www.sencha.com/forum/