I have a tabpanel where I'm capturing a shopping cart on tab one, payment information on tab two, and showing a summary on tab three.
I would like to hide tab two if the shopping cart total is 0.
The problem I'm running into is that when I try to bind to a formula that determines a boolean value for hiding the tab, the tab does not hide.
Ext.define('TestPanel',{
extend: 'Ext.tab.Panel',
xtype: 'testpanel',
title: 'Test Panel',
viewModel:{
data:{
cartTotal: 0
},
formulas:{
hideTabTwo: function(get){
return get('cartTotal') == 0 ? true : false
}
}
},
items:[
{
title: 'Tab 1',
items:[
{
xtype: 'textfield',
bind:{
value: '{cartTotal}'
}
},
{
bind:{html:'Cart Total: {cartTotal}'}
},
{
bind:{
html: 'Hide Tab 2: {hideTabTwo}'
}
}
]
},
{
title: 'Tab 2',
html: 'omg',
bind:{
hidden: '{hideTabTwo}'
}
},
{
title: 'Tab 3',
html: 'lol'
}
]
})
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.create('TestPanel',{
renderTo: Ext.getBody()
})
}
});
I can't see what's going wrong here. If you look at the output of the line html: 'Hide Tab 2: {hideTabTwo}'
in the fiddle, you'll see that it is toggling between true and false.
Any ideas?