-
8 Feb 2011 11:53 PM #1
Tabpanel brokes practices of MVC pattern
Tabpanel brokes practices of MVC pattern
To create Iphone like bottom navbar I should use Tabpanel.
The bad thing here is that instead of controller tabpanel itself is responsible to set activeitems.
I tried to use tabbar separately from tab panel, but found that it is deeply coupled with tab panel and cannot be used without it.
I think you should decouple tabbar from tabpanel, so it can be used as menu control, which change event could be used to controller's actions.
-
9 Feb 2011 3:17 AM #2
I've made a hack to get it work. But I think this should be solved by framework.
Hope you solve this in future versions.Code:app.views.Viewport = Ext.extend(Ext.Panel, { dockedItems: [ new Ext.TabBar({ dock : 'bottom', ui : 'dark', layout: { pack: 'center'}, cardLayout: this.layout, cardSwitchAnimation: this.cardSwitchAnimation, items: [ { iconCls: 'activity', text: 'Activity', controller: app.controllers.activity, action: 'index' }, { iconCls: 'prescriptions', text: 'Prescriptions', controller: app.controllers.prescriptions, action: 'index' }, { iconCls: 'doctors', text: 'Doctors', controller: app.controllers.doctors, action: 'index' }, { iconCls: 'myinfo', text: 'My info', controller: app.controllers.myinfo, action: 'show' } ], listeners: { 'render' : function(bar) { var tabs = bar.query('.tab')[0].activate(); }, 'change': function (bar, currentTab, card) { var tabs = bar.query('.tab'); var previousTab = null; for (var i = 0; i < tabs.length; i++) { if (tabs[i].active) { previousTab = tabs[i]; tabs[i].deactivate(); } } var direction = (bar.items.indexOf(currentTab) < bar.items.indexOf(previousTab)) ? 'right' : 'left'; Ext.dispatch({ controller: currentTab.controller, action: currentTab.action, animation: {type:'slide', direction:direction} }); currentTab.activate(); } } }) ],
-
14 Feb 2011 8:50 AM #3
I'm running into the same problem here. I have cards that don't belong in the bottom tabbar of a tabpanel, but when I render them with the controller the tabpanl starts adding them to the tab bar. Your solution is right on point of what I'm about to write. I wonder if there is something we are missing with best practice here.
Thanks for your post.
-
12 Apr 2011 5:04 AM #4
Same problem here!!!
Sencha released a new Screencast that demonstrates how to create an interface like we imagine. However, even though the example code is using a MVC-like pattern, it does not include controller files. Maybe not a coincidence? Check it out:
http://vimeo.com/22251762
-
7 Jun 2011 5:53 PM #5
Has anyone figured out a better solution to this? Otherwise, I'll have to use lexer's hack (thanks lexer!!!).
This should be handled by the framework, as there is no clean way to use an MVC architecture with tabs.
-
7 Jun 2011 6:11 PM #6
It's not necessarily wrong if Sencha is trying to build a framework that contains HMVC patterns. From my point of view, it's OK to have a hierarchy for some parts of the GUI.
-
7 Jun 2011 6:58 PM #7
-
7 Jun 2011 8:25 PM #8
I was starting a new project with the MVC Model proposed by the videos and suddenly I bumped with this post. What are the recommendations then?? discard the MVC model and do it with the index.js and the Ext structure with the onReady function? Any hint here would be really appreciated as I found the MVC way a bit intricate for people that is just getting to know Sencha Touch. Any advice???
-
8 Jun 2011 10:47 AM #9
-
8 Jun 2011 10:57 AM #10
I ended up using a derivative of lexer's post. Don't use a tab panel, use a toolbar with tabs that you active on your own, and use the rendering approach of the MVC pattern. I personally really like the MVC pattern as it keeps the DOM lightweight. Just mimic the functionality of the tab panel, and use the MVC pattern.
Similar Threads
-
[FIXED-518] Radio/Radiogroup with ']' element in the name brokes form rendering
By fg1tr in forum Ext 3.x: BugsReplies: 2Last Post: 29 Dec 2010, 9:38 AM -
Mediator Pattern and Observer Pattern: alternative architecture to manage events
By mabello in forum Community DiscussionReplies: 0Last Post: 6 Apr 2008, 10:49 AM -
Best practices for loading TabPanel dynamic content
By bdperk in forum Ext 2.x: Help & DiscussionReplies: 9Last Post: 6 Feb 2008, 4:05 PM -
ie brokes my tabs :D
By luke83 in forum Ext 1.x: Help & DiscussionReplies: 15Last Post: 7 Nov 2006, 4:32 PM


Reply With Quote