1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    9
    Answers
    1
    Vote Rating
    0
    spirosdi is on a distinguished road

      0  

    Default Answered: load store on painted event

    Answered: load store on painted event


    Hi all,
    i have a carousel that has a onPainted event binded, in which i load a store with photos and add them in the carousel. The thing is that the photos are actually shown in the carousel after the second time the carousel gets painted. Why this is happening?
    My code:

    Code:
    onFashionCarouselPainted{
            storePhotos.load();
            fashionCarousel = Ext.getCmp('FashionCarousel');
        	fashionCarousel.removeAll();
            storePhotos.each(function(record){
            	fashionCarousel.add({
                	       html: '<h1>' + record.get('title') + '<h1/>'
                     });
            });
            fashionCarousel.setActiveItem(0);
    }
    thank you

  2. Hi spirosdi,

    ah, I looked at your code again and saw another possible error cause.
    Probably the problem of the "delay" is, that your store is simply not loaded at this point of time (ajax is asynchronous).
    You call
    Code:
    storePhotos.load();
    , but direclty after that, you want to go through the records with Ext.each(...).
    What you probably need is the callback functionality of store load, so that you don't loop through the records before the store is loaded.

    Try this:
    Code:
    onFashionCarouselPainted{
        storePhotos.load({
            callback: function(records, operation, success) {
                fashionCarousel = Ext.getCmp('FashionCarousel');
                fashionCarousel.removeAll();
                Ext.each(records, function(current) {
                    fashionCarousel.add({
                        html: '<h1>' + current.get('title') + '<h1/>'
                    });
                });
                fashionCarousel.setActiveItem(0);
    
            },
            scope: this
        });
    }
    Hope that it does the trick ;-)
    Best regards,
    Schildi

  3. #2
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      0  

    Default


    Hi spirosdi,

    did you try to use a different event? I could imagine that initialize is more what you're looking for.
    What I also saw is that there's something special about the painted event in carousels. In the docs it sais
    Note: This event (= painted event) is not available to be used with event delegation. Instead 'painted' only fires if you explicily add at least one listener to it, due to performance reason.
    (see http://docs.sencha.com/touch/2-0/#!/...-event-painted)

    Could also be a reason, but I'm not sure.

    Best regards,
    Schildi

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    9
    Answers
    1
    Vote Rating
    0
    spirosdi is on a distinguished road

      0  

    Default


    Hi Schildi,
    i tried initialize event and the result is still the same... The initialize fires only once so the photos are not getting rendered...
    The painted event is fired (i check it with logger) as i add a listener to it
    onFashionCarouselPainted

    There must be another issue...

  5. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      1  

    Default


    Hi spirosdi,

    ah, I looked at your code again and saw another possible error cause.
    Probably the problem of the "delay" is, that your store is simply not loaded at this point of time (ajax is asynchronous).
    You call
    Code:
    storePhotos.load();
    , but direclty after that, you want to go through the records with Ext.each(...).
    What you probably need is the callback functionality of store load, so that you don't loop through the records before the store is loaded.

    Try this:
    Code:
    onFashionCarouselPainted{
        storePhotos.load({
            callback: function(records, operation, success) {
                fashionCarousel = Ext.getCmp('FashionCarousel');
                fashionCarousel.removeAll();
                Ext.each(records, function(current) {
                    fashionCarousel.add({
                        html: '<h1>' + current.get('title') + '<h1/>'
                    });
                });
                fashionCarousel.setActiveItem(0);
    
            },
            scope: this
        });
    }
    Hope that it does the trick ;-)
    Best regards,
    Schildi

  6. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    9
    Answers
    1
    Vote Rating
    0
    spirosdi is on a distinguished road

      0  

    Default


    You are absolutely right! Thank you!

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi