1. #11
    Sencha User
    Join Date
    May 2011
    Posts
    11
    Vote Rating
    0
    tolbahady is on a distinguished road

      0  

    Default


    Yes, I should have changed the name to (e) or (event),

  2. #12
    Sencha User
    Join Date
    Aug 2011
    Posts
    11
    Vote Rating
    0
    Salim Drame is on a distinguished road

      0  

    Default Delegate issues

    Delegate issues


    Hi all!

    I have different items on each of my itemlist in my list I want to put two different handlers accordingly to where the user tap. Here is some code

    Code:
    listeners: {
                            itemtap: function(view, index, item, e) {
                                console.log(view);
                                var rec = view.getStore().getAt(index);
                                HomeDetails.update(rec.data);
                                BackHome.setTitle(rec.data.game);
                                Home.setActiveItem('homedetails');
                            },
                            delegate: '.notNavigate',
                            itemtap: function() {
                                alert("Coucou");
                            },
                            delegate: '.navigate',
                        }
    This code works when i run each itemtaps events by itself while the other one is hidden. I can't make them work all together though otherwise they do the same thing. How can i fix that?

    Thx for your help

  3. #13
    Sencha Premium Member robboerman's Avatar
    Join Date
    Nov 2007
    Location
    Pijnacker, the Netherlands
    Posts
    70
    Vote Rating
    5
    robboerman is on a distinguished road

      0  

    Thumbs up


    You can also just put the item's id in the dom and fetch it from there:

    Code:
    ...
    tpl: '<tpl for="."><li><img userid="{id}" src="{avatar}" /><h1>{name}</h1></li></tpl>',
    listeners: {
        el: {
            tap: function(evt, elem){
                var userId = elem.getAttribute('userid');
                doSomethingFunkyWithMyUser(userId);
            },
            delegate: 'img'
        }
    }
    ...
    More than one way to do it

    Cheers,
    R
    Rob Boerman

    Appoint solutions BV
    Delft, the Netherlands
    Blog: appointsolutions.com/blog

  4. #14
    Sencha User
    Join Date
    Oct 2011
    Posts
    30
    Vote Rating
    0
    pm.sreejith is on a distinguished road

      0  

    Default


    Quote Originally Posted by tomalex0 View Post
    Hi could anyone tried event delegation in list,.

    I used this to make it work anyway
    Code:
    listeners:{
                    itemtap:function(list, index, item, e){
                        var rec = list.store.data.get(index);
                        var image = e.getTarget("img");
                        if(image){
                            alert("image clicked");
                        }
                    }
                }
    Hi tomalex0,

    I was followed your method which is mentioned above. According to that, I made changes in my application, even though I'm not getting the tap event. Code from my application given below. Please go through it and let me know if it have any issues.

    Code:
    Ext.define('Sencha.view.ContentList', {
        extend: 'Ext.List',
        requires: ['Sencha.store.Contentlist'],    
        xtype: 'contentlist',
        
        config: {
            width:  350,
            itemTpl: '<div><font size="2">{catogory}</font></div>',
            store: 'Contentlist',
            scrollable: 'vertical',
            onItemDisclosure: true,
            scope:this
        },
    
        listeners:{
            itemtap:function(ContentList, index, item, e){
                var rec = ContentList.store.data.get(index);
                var image = e.getTarget("img");
                if(image){
                    alert("image clicked");
                }
            }
        }    
    });
    Thanks in advance

  5. #15
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    Is you itemtap event not working? Also there is no img tag in your tpl.

    Can you explain bit more about what you looking for?
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  6. #16
    Sencha User
    Join Date
    Oct 2011
    Posts
    30
    Vote Rating
    0
    pm.sreejith is on a distinguished road

      0  

    Default


    Hi,

    Code:
    Ext.define('Sencha.view.ContentList', {
        extend: 'Ext.List',
        requires: ['Sencha.store.Contentlist'],    
        xtype: 'contentlist',
        
        config: {
            width:  350,
            itemTpl: '<div><font size="2">{catogory}</font></div>',
            store: 'Contentlist',
            scrollable: 'vertical',
            onItemDisclosure: true,
            scope:this
        },
    
        listeners:{
            itemtap:function(ContentList, index, item, e){
                var rec = ContentList.store.data.get(index);
                var image = e.getTarget("img");
                if(image){
                    alert("image clicked");
                }
            }
        }    
    });
    Sorry, I forgot to repace img tag with div. Just now I done. My aim is to get the category specified in the tpl on the click event.

    Thanks in advance...

  7. #17
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    Did you tried

    Code:
    var rec = ContentList.store.data.get(index);
    console.log(rec)
    console.log(rec.get('catogory'));
    Probably you have catogory value in store record itself. Don't need to get value rendered in tpl
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  8. #18
    Sencha User dobie_'s Avatar
    Join Date
    Sep 2011
    Location
    Seattle, WA
    Posts
    47
    Vote Rating
    0
    dobie_ is on a distinguished road

      0  

    Default


    Quote Originally Posted by hitman01 View Post
    When adding listeners and handlers, is it better to attach something to body or el?
    Also, whats the best way to handle capturing multiple events and assigning different delegates to them?
    Currently I'm using the following solution but it has some performance problems.

    // This has to capture a tap event application wide
    panelObj.body.on({
    tap: function(e, t) {
    // do something
    }});

    // this has to capture double tap only on specific images
    panelObj.body.on({
    delegate: ['img.abc1', 'img.abc2'],
    doubletap: function(e, t) {
    // do something else
    }});
    I'm also curious about the best way to define multiple event handlers.

Similar Threads

  1. When to use event delegation?
    By dolittle in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 4 Nov 2008, 9:35 AM
  2. what is event delegation?
    By illuminum in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 28 Jun 2008, 4:57 PM
  3. Click Delegation Help
    By thejoker101 in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 13 Jan 2007, 11:54 PM
  4. YUI Question : Event Delegation
    By INeedADip in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 23 Oct 2006, 2:08 PM

Thread Participants: 9

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