Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7003531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:04:53+00:00 2026-05-27T21:04:53+00:00

Is there a way to use the Ext.app.Controller control() method, but pass in a

  • 0

Is there a way to use the Ext.app.Controller control() method, but pass in a DOM query? I have a page that contains standard links and would like to add a click handler to them even though they were not created as Ext Buttons.

I’ve tried

Ext.define('app.controller.TabController', {
    extend: 'Ext.app.Controller',

    init: function() {
        console.log("init");
        this.control({
            'a': {
                click: this.changeTab
            }   
        });
    },

    changeTab: function() {
        alert("new tab!");
    }   
});

But clicking on links does not fire the alert.

Is there a way to specify a CSS selector with this.control? Or does it only work with components?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:04:53+00:00Added an answer on May 27, 2026 at 9:04 pm

    I asked this question at SenchaCon this year, the Sencha developers stated that their intent is that DOM listeners should be attached within your view, and the view should abstract them into more meaningful component events and refire them.

    For example, suppose you’re creating a view called UserGallery that shows a grid of people’s faces. Within your UserGallery view class, you would listen for the DOM click event on the <img> tag to receive event and target, and then the view might fire a component event called “userselected” and pass the model instance for the clicked user instead of the DOM target.

    The end goal is that only your views should be concerned with things like interface events and DOM elements while the application-level controller only deals with meaningful user intents. Your application and controller code shouldn’t be coupled to your markup structure or interface implementation at all.

    Sample View

    Ext.define('MyApp.view.UserGallery', {
        extend: 'Ext.Component'
        ,xtype: 'usergallery'
    
        ,tpl: '<tpl for="users"><img src="{avatar_src}" data-ID="{id}"></tpl>'
    
        ,initComponent: function() {
            this.addEvents('userselected');
    
            this.callParent(arguments);
        }
    
        ,afterRender: function() {
            this.mon(this.el, 'click', this.onUserClick, this, {delegate: 'img'});
    
            this.callParent(arguments);
        }
    
        ,onUserClick: function(ev, t) {
            ev.stopEvent();
    
            var userId = Ext.fly(t).getAttribute('data-ID');
    
            this.fireEvent('userselected', this, userId, ev);
        }
    });
    

    Notes on views

    • Extend “Ext.Component” when all you want is a managed <div>, Ext.Panel is a lot heavier to support things like titlebars, toolbars, collapsing, etc.
    • Use “managed” listeners when attaching listeners to DOM elements from a component (see Component.mon). Listeners managed by a components will be automatically released when that component gets destroyed
    • When listening for the same event from multiple DOM elements, use the “delegate” event option and attach the listener to their common parent rather than to individual elements. This performs better and lets you create / destroy child elements arbitrarily without worrying about continuously attaching/removing event listeners to each child. Avoid using something like .select('img').on('click', handler)
    • When firing an event from a view, Sencha’s convention is that the first parameter to the event be scope — a reference to the view that fired the event. This is convenient when the event is being handled from a controller where you’ll need the actual scope of the event handler to be the controller.

    Sample Controller

    Ext.define('app.controller.myController', {
        extend: 'Ext.app.Controller'
    
        ,init: function() {
            this.control({
                'usergallery': {
                    userselected: function(galleryView, userId, ev) {
                        this.openUserProfile(userID);
                    }
                }   
            });
        }
    
        ,openUserProfile: function(userId) {
            alert('load another view here');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to use form fields that does not correspond to database
Is there an easy way to fetch the ManyToMany objects from a query that
Is there any way to use inheritance in database (Specifically in SQL Server 2005)?
Is there a way to use JQuery to cloak or encrypt email addresses on
Is there any way to use a constant as a hash key? For example:
Is there a way to use constants in JavaScript ? If not, what's the
Is there any way to use C# to build a container application where each
Is there a way to use .NET reflection to capture the values of all
Is there a way to use Enum values inside a JSP without using scriptlets.
Is there a way to use THE LOOP in Wordpress to load pages instead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.