I’m using extjs mvc style to create a web application.
I don’t have any direct issue but I’m not sure on how should I handle this code to keep following the mvc pattern.
This is my situation:
- Controller, which detect click event
- View, which has a changePassword method
I’m simply trying to make an ajax request to change the password of a user (notice that the code is currently working, I’m only thinking if I should move a part on the controller).
Currently the code behaves like this:
- Controller detect click event and run changePassword method on the view with a record parameter it passes to
- View open a prompt message that request to the user a new password
- View runs an ajax call and show a successful/error message
What my idea is:
- Controller detect click event and run View.showChangePassword prompt
- View show the prompt and it returns the password insert there to the controller
- Controller runs the ajax call
- Controller runs a View.showChangePasswordResult with param: what is returned by ajax call
Is my idea better than what I’m currently using?
Yes. I would only move
showChangePasswordto the controller too.