2012-12-16 4 views
1

아래 코드의 마지막 두 줄에 항목을 추가하는 방법을 모르겠습니다. flickr의 이미지가 올바르게로드되고 있습니다. TR.view.photoset.Carousel.add (항목) 에러 메시지저장소로드 콜백 함수에서 캐 러셀 구성 요소에 항목을 추가하려면 어떻게합니까?

"Uncaught TypeError: Object function() { return this.constructor.apply(this, arguments); } has no method 'add' "

Ext.define('TR.view.photoset.Carousel', { 
extend: 'Ext.carousel.Carousel', 
alias: 'widget.photosetcarousel', 
config: { 
     store: 'PhotosetPhotos', 
     itemTpl: '<img src="http://src.sencha.io/{[Ext.Viewport.getOrientation()]}/{photo_url}" />', 
     title: 'Flickr Photoset', 
     iconCls: 'hot', 
     iconMask: true, 

     scrollable: { 
      direction: 'vertical', 
      directionLock: true 
     },   
}, 

initialize: function(me) { 
    var store = Ext.getStore('PhotosetPhotos'); 

    store.clearFilter(true); 
    store.filter('photoset', '72157632230262446'); 
    store.load();  

    store.load(function(pictures , operation) { 
     var items = []; 

     Ext.each(pictures, function(picture) { 
      if (!picture.get('photo_url')) { 
       return; 
      } 

      items.push({ 
       xtype: 'flickrimage', 
       picture: picture 
      });    
     }); 

     // fill items into carousel above 
    {???}.add(items); 
    {???}.setActiveItem(0); 
    }); 
} 

을}) 결과;

감사합니다 ...

+0

,'this' 회전 목마가 될 것입니다. –

답변

0

컨베이어의 항목을 주 코드로 채우는 코드를 삽입했습니다. 올러.

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); 
}); 

} 권리 범위와

0

대신 사용해 보셨습니까?

photosetcarousel.setItems(items); 

아니면 회전 목마에게 photosetcarousel의 ID를주고, 다음 시도 : 테스트하지

var photosetcarousel = Ext.getCmp('photosetcarousel'); 
photosetcarousel.setItems(items); 

을 ...

또한 자신의 예를 참조 할 수 있습니다

:

http://web.archive.org/web/20121109164506/http://edspencer.net/2012/02/building-a-data-driven-image-carousel-with-sencha-touch-2.html

+0

아니요, 작동하지 않았습니다. Sencha Touch 2의 참고 문헌과 약간 교묘합니다. 아래에서 해결책을 찾았습니다. – Michael