how to create interceptor like functionality for buttons in extjs 4.0?
I have an existing application built on ExtJS. We have buttons across multiple views. We have a change request that, whenever a button was clicked, some function should be called before the actual logic fires. This function call is applicable for all button click events.
How can we handle this scenario in ExtJS?
What's stopping you from adding the function that's always called to each of the listeners.
click: function(btn) {
functionThatAlwaysRuns();
// rest of your button specific logic here
}
This sounds like code that you can clean up significantly by tying all the buttons to a common listener in a controller, and using the strategy pattern to determine which specific logic to run after the generic function though. A good example can be found here for the strategy pattern: http://encosia.com/first-class-functions-as-an-alternative-to-javascripts-switch-statement/
链接地址: http://www.djcxy.com/p/76398.html上一篇: Extjs MVC嵌套视图事件和异步函数