问题
I'm pretty new to Dojo and I'm wondering about some best practises for building a MVC application. I know there are modules like dojox/app, but it seems like these are made for more complex applications.
It seems like the best way to go is to make custom page-level controller objects with will handle all the page logic, but I'm not quite sure how to fit this piece in the puzzle. What is the proper way to switch between views and passing through parameters through them following a MVC archtiecture.
I have an overview page with list items, each with their own ID. I want to navigate to another page passing through the corresponding item ID so I can retrieve the details for this item externally. What would be the proper way of doing this?
- I could call a method on the corresponding controller (Page1 Controller or Page2 Details controller) directly using a button and passing the listID parameter directly?
- Another way of doing this could be by working with transition states and addling listeners in the page controller to forward to the correct page. Although I'm not quite sure how to pass parameters in this scenario..
- ... any better solutions?
Can anybody shed some light on this? It doesn't seem like there is much documentation/examples on this with the latest versions of dojo (1.9).
Thanks!
回答1:
I will recommend dojox/app since you are already using dojo mobile. It's very simple to get started and can be use for simple apps or very complex apps
Take a look at this resources:
https://github.com/csantanapr/dapp-examples/tree/master/dapp-request
https://github.com/csantanapr/dapp-boilerplate
http://dojotoolkit.org/documentation/tutorials/1.9/dojox_app/contactsList/
来源:https://stackoverflow.com/questions/18171817/how-to-best-apply-an-mvc-architecture-in-dojo-mobile-custom-controllers