[sapui5] Always remember to pass controller object when initiate fragment
Hi,
I've got painful days searching to get this error.
Here's the problem:
When I press the button, it does not trigger the function in the controller.
I don't know why... until today.
Each fragment to have a controller, but my code make the fragment get the wrong controller,
Instead of getting controller of that view, they misunderstood with the window object, because I initiate the fragment where the context of this is the window object:
It's good to init your controller's properties in the top to provide an overview of global properties. But be aware of this keyword, which is very dynamic in Javascript.
---V---
I've got painful days searching to get this error.
Here's the problem:
Problem
I can not get any event in above table.When I press the button, it does not trigger the function in the controller.
I don't know why... until today.
UI design |
Reason
The problem comes from my initiation of the fragment to be used as table items.Each fragment to have a controller, but my code make the fragment get the wrong controller,
Instead of getting controller of that view, they misunderstood with the window object, because I initiate the fragment where the context of this is the window object:
The code in the browser console |
Solution
If you init fragment to use in the view, init it in the event onInit() of view is the best, which the controller already loaded into this key word:
Solution code in Web IDE |
Cheers!
---V---
Nhận xét
Đăng nhận xét