我對Sencha Touch很新穎。我非常喜歡這款產品,但是我很難解決這個問題。請幫忙。我已經在這3天了!如何在Sencha Touch的localstorage中重新使用存儲的數據?
我能夠將數據存儲在localstorage中以便重複使用。但是我無法在網址中的任何其他面板(或頁面)和參數中重複使用商店中的數據。我可以通過在事件處理程序中調用它來使用像app.UserStore.getAt(0).get('id')這樣的數據,但不能在url的參數或我指定的值中使用。
這是不是可以在其他地方使用app.UserStore.getAt(0).get('id')格式?如果是這樣,我有什麼選擇來解決這個問題?
- 在localStorage的存儲的數據在登錄後
Ext.regModel('User', {
fields: ['id', 'email'],
proxy: { type: 'localstorage', id: 'user-localstorage' }
});
app.UserStore = new Ext.data.Store({
model: 'User',
storeId: 'ConfigStore',
autoLoad: true
});
- 源在localStorage的重用數據(請app.UserStore.getAt(0)獲得( 'ID')在源)
- 我可以看到存儲的數據*
**我得到一個錯誤,由於這些代碼。 (該頁面不顯示)**
initComponent: function(){
var toolbarBase = {
xtype: 'toolbar',
title: 'Group Chat'
};
toolbarBase.items = [{ xtype: 'spacer', flex: 1 }, {
iconCls: 'action',
iconMask: true,
scope: this,
ui: 'plain',
handler: function(){
Ext.Msg.alert('Login Sucess', *app.UserStore.getAt(0).get('id')*, Ext.emptyFn);
}
}];
this.dockedItems = toolbarBase;
var searchModel = Ext.ModelMgr.getModel("Search");
var search = new searchModel({
query: **app.UserStore.getAt(0).get('id')**
});
var store = search.tweets();
var tweetList = {
cls: 'timeline',
emptyText : '<p class="no-searches">No Message Found</p>',
disableSelection: true,
store: store,
plugins: [ {
ptype: 'pullrefresh'
}],
itemCls: 'tweet',
itemTpl: new Ext.XTemplate(
'<div class="avatar"<tpl if="profile_image_url"> style="background-image: url({profile_image_url})"</tpl>></div>',
'<div class="x-tweetanchor"></div>',
'<div class="tweet-bubble">',
'<div class="tweet-content">',
'<h2>{from_user}</h2>',
'<p>{text:this.linkify}</p><strong></strong>',
'<span class="posted">{created_at}</span>',
'</div>',
'</div>',
{
linkify: function(value) {
return value.replace(/(http:\/\/[^\s]*)/g, "<a target=\"_blank\" href=\"$1\">$1</a>");
}
}
)
};
this.list = new Ext.List(Ext.apply(tweetList, {
fullscreen: true
}));
this.listpanel = new Ext.Panel({
layout: 'fit',
items: this.list,
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
ui: 'gray',
items: [{
xtype: 'textfield',
placeHolder: 'Share your thoughts with your Peers',
name: 'searchfield'
}]
}]
});
this.items = this.listpanel;
this.list.store.load();
app.views.ChatList.superclass.initComponent.call(this);
}
您是否收到JavaScript錯誤? – 2011-04-28 22:44:11