Results 1 to 4 of 4

Thread: searchfield does not issue 'action' event.

  1. #1

    Default Answered: searchfield does not issue 'action' event.

    Hello, I'm just finding my way through sencha touch but I've come across this issue:

    I added the following declaration to a toolbar container. When I press <enter> in the search field I get "search" output to the console but do not get "action"

    Can anyway explain what control event I should be using and why "action" is not raised?

    Code:
            
              {
                    xtype: 'searchfield',
                    placeHolder: 'Search',
                    name: 'searchfield',
                    action: function( a, b ) { console.log( 'action' ) },
                    listeners: {
                        el: {
                            search: function( o, v ) {  console.log( 'search' ) }
                        },
                        scope: this
    
    
                    }
                },

  2. You have to listen to events... they don't fire a method on a class.

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

    Default

    action fires but you aren't listening to it properly:

    Code:
    new Ext.form.FormPanel({
        fullscreen : true,
        items      : [
            {
                xtype     : 'searchfield',
                label     : 'search',
                listeners : {
                    action : function() {
                        console.log('hi');
                    }
                }
            }
        ]
    });
    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

  4. #3

    Default Additional clarification if you have time

    Thanks for that. I guess it makes sense.

    But, just so I don't wind up asking the same question again later....


    The online docs for senchatouch list 'action' as an event of Ext.forms.Search component.

    In your answer I have to attach a listener. To me this means I'm listening for the html dom event from the HTML5 search field. Not to an even on the component.

    Are the events listed in sencha docs the HTML events of the senchtouch component events? Or, is there even a difference?

    Everything I know about this fits in thimble and was learned for this screencast.

    http://www.sencha.com/learn/intro-to-listeners/

    So I would be very grateful for anything you can do to clear up the question of when to listen for an event and when to define an event handler on a component.

    The source for Ext.form.text does add an event for 'action' when events are added in this fashion are the component events or do we 'listen' for them


    initComponent: function() {
    this.addEvents(

    'focus',

    'blur',

    'keyup',

    'change',

    'action'
    );

    this.enableBubble('action');




    Thanks,

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

    Default

    You have to listen to events... they don't fire a method on a class.
    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

Posting Permissions

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