2012-12-27 81 views
1

是否有ExtJS的MVC任何方式把一個按鈕處理程序控制器裏,這樣的事情:ExtJS的MVC把控制器內的按鈕處理

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

還是我必須用別的東西像click事件?

回答

6

那麼,你的代碼確實定義了按鈕來收聽(storage_settings button[action=submit_settings]),但不是要收聽的事件(除非有一個名爲handler的事件沒有)。

handler是一個配置選項,你可以給你如果你不使用MVC(因此處理程序將在視圖代碼中)。由於您使用的是MVC,因此您應該聽取click事件。所以:

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

這也應該工作:

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