1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    386
    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
    386
    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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar