-
21 Dec 2011 1:29 PM #1
Answered: Navigation View - Navigation Bar Problem
Answered: Navigation View - Navigation Bar Problem
Hi,
when I want to add some items to my navigationBar like this:
Then my push() command for a new view says:Code:// Navigation Bar navigationBar: { docked: 'bottom', height: 40, items: [ { xtype: 'button', text: 'test' } ] },
If I remove the items list from navigationBar everything works fine. But I need to add a button to the navigationBar. How can I do this?HTML Code:Uncaught TypeError: Cannot call method 'getText' of null
-
Best Answer Posted by mitchellsimoensCode:
Ext.define('MyClass', { .... initialize: function() { this.callParent(arguments); this.on({ painted : function() {} }); } });
-
21 Dec 2011 2:31 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
Looks like this is because of this line in Ext.navigation.Bar:
Where it tries to resolve the back button but it can't be found so down() returns null. If you wait till the view is painted and then you can add the button. The back button will still show at the first button when it is shown.Code:if (!this.backButton) { this.backButton = this.down('button[ui=back]'); }
Code:var view = Ext.create('Ext.navigation.View', { fullscreen : true, navigationBar: { docked: 'bottom', height: 40 }, items : [ { html : 'Test' } ], listeners : { buffer : 50, painted : function(view) { var bar = view.getNavigationBar(); bar.add({ xtype : 'button', text : 'Test', handler : function() { view.push({ title : 'A new view', html : 'Some new content' }); } }); } } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
22 Dec 2011 2:16 AM #3
Here's my code - painted event is again not working ... no console.log output.
Is the var view declaration that I made possible like this in MVC structure? I think the main problem ist, that the painted event isn't triggered by the view - any other possibilities?
Code:var view = Ext.define('App.view.Viewport2', { extend: 'Ext.NavigationView', xtype: 'headerscreen', require: ['HomeCarousel', 'ProductSlider'], // Configuration of the view config: { fullscreen: true, defaults: { scrollable: false, styleHtmlContent: true }, // Navigation Bar navigationBar: { docked: 'bottom', height: 40, }, // NavigationView Items items: [{ title: 'Home', layout: 'vbox', // Different Items on the view items: [ { id: 'header', height: 125, docked: 'top', xtype: 'container', html: '<h1>Just one more</h1><ul id="menu"><li id="latest">Latest</li><li><a href="/view/About.js" id="random">Random</a></li></ul>' }, { xtype: 'button', id: 'aboutButton', text: 'About', handler: function() { //this.push({xtype: 'aboutscreen'}); } }, { xtype: 'home_carousel' }, ] }], listeners : { buffer : 50, painted : function(view) { var bar = view.getNavigationBar(); console.log('LISTENER TEST'); bar.add({ xtype : 'button', text : 'Test', handler : function() { view.push({ title : 'A new view', html : 'Some new content' }); } }); } } }, // Initialize Block initialize: function() { console.log('>> HEADER [created]'); this.callParent(); } });
-
3 Jan 2012 7:35 AM #4
same problem - NavigationView listeners don't fire
same problem - NavigationView listeners don't fire
This is the code of my viewport. I tried all types of events but nothing is fire no matter what.
I think it's a bug...:/
Code:Ext.define('MDA.view.Viewport', { extend: 'Ext.NavigationView', id: 'myview', xtype: 'my-viewport', config: { layout: { type:'card' }, fullscreen: true, listeners : { painted : function(view) { console.log(view,"dddd"); }, }, .... } });
-
3 Jan 2012 7:41 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
You should define listeners within initialize... not the config object.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Jan 2012 7:52 AM #6
thanks for the fast replay

what do you mean by saying "You should define listeners within initialize"?
where should i do it? can you attach a sample code?
-
3 Jan 2012 8:10 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
Code:Ext.define('MyClass', { .... initialize: function() { this.callParent(arguments); this.on({ painted : function() {} }); } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
4 Jan 2012 12:30 AM #8
I thought i did b4...anyway thanks that worked!



Reply With Quote