Attach ExtJS MVC controllers to DOM elements, not components

前端 未结 5 1436
执念已碎
执念已碎 2020-12-13 05:10

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

5条回答
  •  Happy的楠姐
    2020-12-13 05:46

    I had the same problem recently (mixing mvc with some non components). Just thought I'd throw this in as an answer as it seems pretty simple and works for me :)

    Ext.define('app.controller.TabController', {
        extend: 'Ext.app.Controller',
    
        init: function() {
            console.log("init");
            this.control({
               /* 'a': {
                    click: this.changeTab
                } */  
            });
    
        var link = Ext.dom.Query.selectNode('a');
    
        Ext.get(link).on('click', this.changeTab);
    
        },
    
        changeTab: function() {
            alert("new tab!");
        }   
    });
    

提交回复
热议问题