Search code examples
javascriptextjsextjs4dom-eventsextjs-mvc

ExtJs MVC put a button handler inside a controller


Is there any way in ExtJs MVC to put a button handler inside a controller, something like this:

this.control({
    'storage_settings button[action=submit_settings]': {
     handler: this.submit_settings_handler
  })

Or do I have to use something else like a click event?


Solution

  • Well, your code does define the button to listen to (storage_settings button[action=submit_settings]) but not the event to listen to (unless there's an event called handler, which there isn't).

    handler is a config option you can give if your'e not using MVC (thus the handler will be within the view code). Since you are using MVC, you should listen to the click event. So:

    this.control({
        'storage_settings button[action=submit_settings]': {
             click: this.submit_settings_handler
    });
    

    This should also work:

    this.control({
        'storage_settings button[action=submit_settings]': {
             click: function( aButton, aEvent, aOptions )
             {
             }
    });