on 01-07-2016 1:20 PM
I have a workflow-like requirement for my app and I need to change the event handler of a common button depending on the status of the workflow.
Research revealed only one example, which stores the event handler function in a variable: Correctly removing event listeners in SAPUI5
Looking into the API I found it's also possible without use of a variable like this:
btn.detachPress(btn.mEventRegistry.press[0].fFunction);
btn.attachPress(oController.onMyNewHandlerPress);
Buttons generally only have one intended press event handler, so referencing press[0] seems OK to me.
This post should let the community validate this technique as an alternative to the one in the link above, or perhaps propose an even better one.
Possibly the OpenUI5 team might like the idea to add to the API a detachPress() - no args, or detachAllPress(), to just blanket reset all event handlers.
Thanks
Jason
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.