1. #1
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    36
    Vote Rating
    0
    frankpeng is on a distinguished road

      0  

    Default Unanswered: How to capture a key event from a form in MVC way?

    Unanswered: How to capture a key event from a form in MVC way?


    I can capture a key [Enter] event from a form (under view) in MVC as follows.

    Code:
    Ext.define('SC.view.case_search.AdvSearchPopup', {
        extend: 'Ext.window.Window',
        alias : 'widget.advsearchpopup',
        id:     'advsearchpopup_id',
        title : 'advance case search ',
        autoShow: true,    
        width: 600,
        height: 360,
        defaults: {
            margin: '5,5,0,5'
        },
          listeners: {
               afterRender: function(thisForm, options){
                   this.keyNav = Ext.create('Ext.util.KeyNav', this.el, { 
                   enter: function(a, b) { alert("aaa"); },
                   scope: this
                   });
               }
        },
        
      
        initComponent: function() {
    ...
    However, I wonder if this event needs to be coded under controller, such as the chuck below. It just doesn't work since it has a nested event "enter" within "afterRender". Any suggest to get it right? Thanks

    Code:
    Ext.define('SC.controller.Cases', {
        extend: 'Ext.app.Controller',    
        views: [ ...,  'case_search.AdvSearchPopup'    ],
        init: function() {
            
            this.control({
                
                 'advsearchpopup ': {
                      afterRender: function(thisForm, options){
                          this.keyNav = Ext.create('Ext.util.KeyNav', this.el, { 
                          enter: function() { alert("446"); },
                          scope: this
                          });
                      } 
                    });        
        },
        ...

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    There is no 'afterRender' event, it is 'afterrender'.

    Also, please post in the appropriate forum, I have moved this to the Ext JS 4 Q&A forum
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    36
    Vote Rating
    0
    frankpeng is on a distinguished road

      0  

    Default


    I just tried. It worked for both 'afterRender' and 'afterrender' from listerners (which is a non-MVC way). I need to find a solution in MVC way. Thanks in advance.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    does the afterrender listener fire in the controller?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1