Sencha Touch 2.x Forums /
Sencha Touch 2.x: Discussion /
Proper/appropriate way to get references to objects
I'm just learning Sencha, and have seen different ways to get references to objects like views. I want to ensure that I'm doing it in a proper way that isn't spawning new instances, etc.
I use the technique below to navigate to cards in a card layout, which works well from a UI perspective. Is ComponentQuery.query a good way to get object references?
var mView = Ext.ComponentQuery.query("mainview");
var moreMessagesView = Ext.ComponentQuery.query("moremessages");
This logic is better served in a controller and then use the 'refs' config. This will let you get references to views and keep the logic of switching views out of your UI layer. Plenty of examples / posts for using 'refs' in the forums
Thanks so much. I'll look into incorporating the obj references there instead. I have started to use refs for some things, but don't fully understand its behavior yet. Seems powerful though.
Take a look at the following. Should be helpful as examples of mvc and using the new features: