Sencha touch 如何从存储加载回调函数向旋转木马组件添加项目?
我不知道如何在下面最后两行代码中添加项。flickr中的图像正在正确加载。TR.view.photoset.Carousel.additems导致错误消息 未捕获的TypeError:对象函数{返回this.constructor.applythis,arguments;}没有方法“add” })Sencha touch 如何从存储加载回调函数向旋转木马组件添加项目?,sencha-touch,sencha-touch-2,jscript,Sencha Touch,Sencha Touch 2,Jscript,我不知道如何在下面最后两行代码中添加项。flickr中的图像正在正确加载。TR.view.photoset.Carousel.additems导致错误消息 未捕获的TypeError:对象函数{返回this.constructor.applythis,arguments;}没有方法“add” }) 谢谢你的帮助……你试过这个吗 photosetcarousel.setItems(items); 或者给旋转木马一个photosetcarousel的id,然后尝试: var photosetcar
谢谢你的帮助……你试过这个吗
photosetcarousel.setItems(items);
或者给旋转木马一个photosetcarousel的id,然后尝试:
var photosetcarousel = Ext.getCmp('photosetcarousel');
photosetcarousel.setItems(items);
未经测试
你也可以参考他的例子:
我将用于填充旋转木马中项目的代码放入主控制器
Ext.define('MY.controller.Main' , {
extend: 'Ext.app.Controller',
// define a reference to the mycarousel view
refs: [
{
ref: 'mycarouselView',
selector: '#mycarousel'
}
],
// let the control call the init function of the carousel
init: function() {
this.control( {
'#mycarousel': {
initialize: 'initMycarousel'
}
});
},
// then I can access the carousel view and fill it ...
initMycarousel: function() {
var carousel = this.getMycarouselView();
var store = Ext.getStore('MycarouselPhotos');
store.clearFilter(true);
store.filter('photoset', '72157631990018061' );
store.load();
store.load( function(pictures , operation ) {
var items = [];
Ext.each(pictures, function(picture) {
if (!picture.get('photo_url')) {
return;
}
items.push({
xtype: 'image',
src: picture.data.photo_url
});
});
// fill items into carousel
carousel.setItems(items);
carousel.setActiveItem(0);
});
}如果范围合适,这将是旋转木马。不,它不起作用。Sencha Touch 2中的引用有点棘手。我发现解决方案如下:
Ext.define('MY.controller.Main' , {
extend: 'Ext.app.Controller',
// define a reference to the mycarousel view
refs: [
{
ref: 'mycarouselView',
selector: '#mycarousel'
}
],
// let the control call the init function of the carousel
init: function() {
this.control( {
'#mycarousel': {
initialize: 'initMycarousel'
}
});
},
// then I can access the carousel view and fill it ...
initMycarousel: function() {
var carousel = this.getMycarouselView();
var store = Ext.getStore('MycarouselPhotos');
store.clearFilter(true);
store.filter('photoset', '72157631990018061' );
store.load();
store.load( function(pictures , operation ) {
var items = [];
Ext.each(pictures, function(picture) {
if (!picture.get('photo_url')) {
return;
}
items.push({
xtype: 'image',
src: picture.data.photo_url
});
});
// fill items into carousel
carousel.setItems(items);
carousel.setActiveItem(0);
});