1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    30
    Answers
    2
    Vote Rating
    0
    amsoft2001 is on a distinguished road

      0  

    Default Answered: TAP event in controller

    Answered: TAP event in controller


    I am using touch 2.3 and I learned from another thread that "Controller does not support event delegation". Is this still true with V2.3?

    I have a Controller config like this

    Code:
    config: {
            refs: {
                friendList: '#friendList'
            },
            control: {
                friendList: {
                    tap: 'startChat'
                }
            }
        }
    But it does not catch the 'tap' event, untill I manually relay the event from the view like this

    Code:
    initialize: function(me, eOpts){
        this.relayEvents(this.element, ['tap']);
    }
    Do I need to manually relay all the different kind of events from all the views? Can't I just create the references into the Controller and listen for the events?

  2. The Container class does not have a "tap" event either, check this http://docs.sencha.com/touch/2.3.1/#!/api/Ext.Container

    And now that I'm getting a better idea about what you are trying to do, I think you might be using a DataView instead http://docs.sencha.com/touch/2.3.1/#!/guide/dataview

    The DataView object will let you define a template, pretty much the same way you are already doing it, bind it to a store and so on.

  3. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    698
    Answers
    41
    Vote Rating
    40
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by amsoft2001 View Post
    Can't I just create the references into the Controller and listen for the events?
    I do this all the times. I don't see why this shouldn't work...

  4. #3
    Sencha User Diego Garcia's Avatar
    Join Date
    Jan 2012
    Location
    San José, Costa Rica.
    Posts
    81
    Answers
    13
    Vote Rating
    7
    Diego Garcia is on a distinguished road

      0  

    Default


    I think its because the list itself does not have a "tap" event. I think you need to "listen" the "itemtap" event instead, but that depends on what are you trying to do.
    We are a community, let's behave like that.

  5. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    60
    Answers
    3
    Vote Rating
    0
    kidqn is on a distinguished road

      0  

    Default


    #friendList is itemId, id or xtype which you are using

  6. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    60
    Answers
    3
    Vote Rating
    0
    kidqn is on a distinguished road

      0  

    Default


    Quote Originally Posted by Diego Garcia View Post
    I think its because the list itself does not have a "tap" event. I think you need to "listen" the "itemtap" event instead, but that depends on what are you trying to do.
    yep it is solution.

  7. #6
    Sencha User
    Join Date
    Nov 2013
    Posts
    30
    Answers
    2
    Vote Rating
    0
    amsoft2001 is on a distinguished road

      0  

    Default


    Actually #friendList is a container defined as


    .....
    xtype: 'container',
    scrollable: true,
    cls: 'chat-container',
    id: 'friendList',
    ......


    What I am trying to do is, I am loading some data inside the container using template. This template creates some square boxes (DIV) inside the container. Those boxes has a link (<a>) inside, and I want to listen for the TAP event on those links...


    The items are loaded runtime using store and model.. sample code is below


    Code:
    initialize: function(me, eOpts){
    	this.relayEvents(this.element, ['tap']);
    	var userStore = Ext.create('MyDesireSencha.store.Friends');
    	userStore.load({
    		params:{user_id: 1},
    		callback: function(records, operation, success) {
    			console.log(records);
    			this.setData(records);
    		},
    		scope: this
    	});
    }
    and the template is like this

    Code:
    tpl: [
    	'<tpl for=".">',
    		'<div class="thumb">',
    			'<img src="{data.image}">',
    			'<div class="name">{data.name}</div>',
    			'<div class="status">',
    				'<a href="#12" onclick="return false">',
    					'<span>CHAT</span>',
    					'<span class="indicator {data.status}"></span>',
    				'</a>',
    			'</div>',
    		'</div>',
    	'</tpl>'
    ].join(''),
    Note: I am following MVC pattern

  8. #7
    Sencha User
    Join Date
    Mar 2012
    Posts
    60
    Answers
    3
    Vote Rating
    0
    kidqn is on a distinguished road

      0  

    Default


    What you catch tap event of links for?
    you use
    Code:
    control: {
                friendList: {                tap: 'startChat'            }         }
    so you should create startChat function instead of initialize function.

  9. #8
    Sencha User
    Join Date
    Nov 2013
    Posts
    30
    Answers
    2
    Vote Rating
    0
    amsoft2001 is on a distinguished road

      0  

    Default


    Hi, I do have a startChat function. That is not a problem. The problem is, if I don't write this line
    Code:
    this.relayEvents(this.element, ['tap']);
    My listener function does not get fired.

  10. #9
    Sencha User Diego Garcia's Avatar
    Join Date
    Jan 2012
    Location
    San José, Costa Rica.
    Posts
    81
    Answers
    13
    Vote Rating
    7
    Diego Garcia is on a distinguished road

      0  

    Default


    The Container class does not have a "tap" event either, check this http://docs.sencha.com/touch/2.3.1/#!/api/Ext.Container

    And now that I'm getting a better idea about what you are trying to do, I think you might be using a DataView instead http://docs.sencha.com/touch/2.3.1/#!/guide/dataview

    The DataView object will let you define a template, pretty much the same way you are already doing it, bind it to a store and so on.
    We are a community, let's behave like that.

  11. #10
    Sencha User
    Join Date
    Nov 2013
    Posts
    30
    Answers
    2
    Vote Rating
    0
    amsoft2001 is on a distinguished road

      0  

    Default


    Hi Diego, That's nice.. I'll look into that.. But do you have any idea on how to add a listener to dynamic items? In this case the link? They are loaded runtime and what is the best way to handle their events?Kind RegardsRakesh

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