-
16 Nov 2011 1:08 PM #1
Unanswered: Toolbar remove/insert issue
Unanswered: Toolbar remove/insert issue
I have a view where I insert a button in my toolbar
Code:init: function() { this.getController("Viewport").getViewportToolbar().insert(2, {xtype: "button", iconCls: 'info', cls: "viewportGoButton", view: "Invite", align : 'right', hidden: false}); },However this gives me the error:Code:Then I go to another view - this button is still present - I now want to remove it and add another: init: function() { this.getController("Viewport").getViewportToolbar().removeAt(2); this.getController("Viewport").getViewportToolbar().insert(2, {xtype: "button", iconCls: 'info', cls: "viewportGoButton", view: "Invite", align : 'right', hidden: false}); },
If I do not use remove I have 2 buttons. If I use '3' for the new button it doesn't show.Code:Uncaught TypeError: Cannot read property 'dom' of null Ext.define.insertItemsencha-touch-all-debug.js:32577 Ext.define.doItemAddsencha-touch-all-debug.js:32350 Base.implement.callParentsencha-touch-all-debug.js:2768 Ext.define.doItemAddsencha-touch-all-debug.js:32677 Ext.define.onItemAddsencha-touch-all-debug.js:32312 Ext.define.onAdd
How do I replace buttons without getting this error?
-
16 Nov 2011 2:12 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,640
- Vote Rating
- 435
- Answers
- 3106
This is working for me against our latest code:
Code:Ext.create('Ext.Panel', { fullscreen : true, items : [ { xtype : 'toolbar', docked : 'top', items : [ { text : 'Test', handler : function(btn) { var toolbar = btn.up('toolbar'); toolbar.removeAt(2); toolbar.add({ text : 'New', ui : 'confirm' }); } }, { text : 'Another Button' }, { text : 'Remove Me' } ] } ] });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.
-
16 Nov 2011 4:07 PM #3
It seems to be an issue with align:right and navigationbar. Please try this example - it causes the same issue and does not remove button (though in my app the button gets removed)
Code:xtype : 'navigationbar', docked : 'top', items : [ { text : 'Test', handler : function(btn) { var toolbar = btn.up('navigationbar'); toolbar.removeAt(2); toolbar.add({ text : 'New', ui : 'confirm', align: 'right' }); } }, { text : 'Another Button' }, { text : 'Remove Me' } ] },
-
21 Nov 2011 9:20 AM #4
Could someone from Sencha please try above code example? Sounds like a bug but would like a more experience dev to try it


Reply With Quote