简体   繁体   中英

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?

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 )
         {
         }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM