Results 1 to 4 of 4

Thread: toggleGroup Listener?

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    24
    Answers
    1

    Default toggleGroup Listener?

    Is there a listener for a whole set of Buttons with a toggleGroup, or do I have to listen to each button?

    View
    Code:
    {	xtype: 'container',
    	id: 'buttonGroupContainer',
    	columnWidth: 0.52,
    	items: [
    		{
    			xtype: 'button',
    			id: 'hrs0',
    			text: '0',
    			toggleGroup: 'forecastButtons',
    			pressed: 'true'
    		},
    		{
    			xtype: 'button',
    			id: 'hrs24',
    			text: 24,
    			toggleGroup: 'forecastButtons'
    		},
    		{
    			xtype: 'button',
    			id: 'hrs48',
    			text: 48,
    			toggleGroup: 'forecastButtons'
    		},
    		{
    			xtype: 'button',
    			id: 'hrs72',
    			text: 72,
    			toggleGroup: 'forecastButtons'
    		}
    	]
    }

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451
    Answers
    3997

    Default

    If you aren't using MVC then you would have to listen in each button.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    24
    Answers
    1

    Default

    I am using MVC. Here's my controller block. I just listen to all buttons at once, which catches two events. Is there a way to only catch one event for the whole group? A different selector maybe?

    Code:
    init: function() {        
    console.log('forecast init');
            
            this.control({
                '#buttonGroupContainer button': {
                    toggle: this.forecastToggle
                }
            })
        },
        
        forecastToggle: function(btn, pressed) {
            if(pressed) {
                //fire event for btn id
            }
        }

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451
    Answers
    3997

    Default

    The based on the componentquery you should be able to have the listener listen for each button
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •