Question

ExtJS 4.1 & DeftJS 0.6.8

The documentation says "References to view components can be established via the control annotation and view-relative component query selectors"

Documentation example:

control: {
        submitButton: 'panel > button[text="Submit"]'
    }

So in my case I want to get access to a menu's button that is nested like this:

  ...
  extend: 'Ext.tree.Panel',
  lid: 'mytreepanel',

  dockedItems: [{
     xtype: 'toolbar',
     lid: 'mybbar',
     items: [{
        xtype: 'splitbutton',
        lid: 'mysplitbutton',
        menu: {
           lid: 'mymenu',
           items: [{
              lid: 'createFolder',
              text: 'Create folder',
           }]
        }
     }]
  }]

My attempts:

control: {
         createFolder: {
            selector : '[lid=createFolder]',
         // selector : 'menu[lid=createFolder]',
         // selector : 'mytreepanel > menu[lid=createFolder]',
         // selector : 'treepanel > toolbar > splitbutton > menu[lid=createFolder]',
            listeners: {
               click: 'createFolder'
            }
         }
}

Nothing worked. Can anyone point me to the right direction?

Was it helpful?

Solution 2

The solution was to add mixins: ['Deft.mixin.Controllable'] which I forgot to make the view controllable.

So now everything works fine with:

createFolder: {
            selector : '[lid=createFolder]',
            listeners: {
               click: 'createFolder'
            }
         }

OTHER TIPS

I don't know in which documentation you found your example (control: { submitButton: 'panel > button[text="Submit"]' }), but it doesn't work for me at all.

By following sencha documentation I've created following controller class:

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

    init: function() {
        this.control({
            '[lid=mytreepanel] menu[lid=mymenu] menuitem[lid=createFolder]': {
                click: function(){ alert(123); }
            }
        });
    }
});

With this definition of control click is working. Also note how the click handler is attached. You must provide callback, not a string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top