1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    393
    Answers
    14
    Vote Rating
    16
    digeridoopoo will become famous soon enough

      0  

    Default Unanswered: Dynamically created components - how to delegate by id in tap listener?

    Unanswered: Dynamically created components - how to delegate by id in tap listener?


    Hi,

    I am having trouble getting a tap listener to work that detects individual items (images) that are created dynamically. Here is the component that generates items and loops through the store:

    Code:
        var carouselpage = Ext.create('Ext.Component',{
            data: recordsforpage,
            tpl: [
            '<tpl for=".">',                   
            '<img src={data.imgUrl} id="{data.id}" width="202px"/>',
            '</div>',
            '</tpl>'
            ]
        });
    As you can see, the image and ids are taken from the store. So I have multiple items in a carousel page. So far so good. I have managed to setup a tap listener on the carousel itself which works, but I am unable to detect the individual items (images) in the carousel.

    Is there a way I can delegate by id somehow? Here is the carousel (generate items are in a controller):

    Code:
    Ext.define('MyApp.view.MyCarousel', {
        extend: 'Ext.carousel.Carousel',
    
    
        config: {
            id: 'mycarousel',
            listeners: [
                {
                    fn: 'onMycarouselShow',
                    event: 'show'
                }
            ]
        },
    
    
        onMycarouselShow: function(component, eOpts) {
            component.element.on({
                // delegate : 'img',
                tap: function(){Ext.Msg.alert('tap called');},
            scope:component});
        }
    
    
    });
    Thanks for any help,

    :-)

  2. #2
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    393
    Answers
    14
    Vote Rating
    16
    digeridoopoo will become famous soon enough

      0  

    Default I nearly figured it out...

    I nearly figured it out...


    I nearly figured it out. If you put a listener on the carousel like this...

    Code:
            component.element.on({
                tap: function(list, index, target, record, e, eOpts){Ext.Msg.alert('tap called');
                 console.log(index);
                },
            scope:component});
        }
    ...I get this in the console:

    Code:
    <img src="resources/images/8.jpg" id="Thumb8" width="202px">
    It doesn't seem to be grabbing the index number properly. Maybe because its not really a list is it, it's a component? I put this in there in the params 'list, index, target, record, e, eOpts'

    Any ideas how I can get the ID?

    :-)

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