我对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