setActiveItem() passing data sencha touch
在此商店进行视图更改时,我想使用setActiveItem()发送数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | Ext.define('SkSe.store.Places',{ extend:'Ext.data.Store', config:{ autoDestroy: true, model:'SkSe.model.Places', //hardcoded data data: [ { name: 'Caffe Bar XS', //naziv objekta icon: 'Icon.png', //tu bi trebala i?i ikona kategorije kojoj pripada stamps: 'stamps1' //broj"stampova" koje je korisnik prikupio }, { name: 'Caffe Bar Mali medo', icon: 'Icon.png', stamps: 'stamps2' }, { name: 'Caffe Bar VIP', icon: 'Icon.png', stamps: 'stamps3' } ] //dynamic data (Matija) //remember to change the icon path in"Akcije.js -> itemTpl" /*proxy:{ type:'ajax', url:'https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyCFWZSKDslql5GZR0OJlVcgoQJP1UKgZ5U', reader:{ type:'json', //name of array where the results are stored rootProperty:'results' } }*/ } }); |
这是我的详细信息控制器,应从场所存储获取数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | Ext.define('SkSe.controller.Details', { extend: 'Ext.app.Controller', config: { refs: { placesContainer:'placesContainer', Details: 'details' }, control: { //get me the list inside the places which is inside placesContainer 'placesContainer places list':{ itemsingletap:'onItemTap' //itemtap:'onItemTap' } } }, onItemTap:function(list,index,target,record){ console.log('omg'); var addcontact= Ext.create('SkSe.view.Details', { xtype:'details', title:record.data.name, data:record.data }); var panelsArray = Ext.ComponentQuery.query('details'); console.log(panelsArray); Ext.Viewport.add(addcontact); addcontact.update(record.data.name); Ext.Viewport.setActiveItem(addcontact); console.log(record.data.name); } }); |
我想从上面的places.js模型发送名称记录。我听说您不能使用setActiveItem传递数据,但应该创建一个更新视图的函数(不,我不能在此处使用pop和push)。
我对sencha touch语法不是很熟悉,我不确定要使用什么功能,显然更新功能不是。
我稍微改变了您的逻辑,但提供了一个我认为您要尝试执行的工作示例。
SenchaFiddle与我在计算机上运行的内容略有不同,但是您应该可以理解。
加载的初始列表从您的商店中获取数据,并且在itemtap上将新视图推送到视口中。
您将需要添加一个导航按钮以从view.View返回列表,并为细节提供更好的布局。我建议使用自定义样式的嵌套容器或面板以使细节恰到好处。另外,您也可以在其中放置完整的html代码段,并根据需要布置所有数据。
很乐意为您提供更多帮助。
提琴:http://www.senchafiddle.com/#XQNA8