Question

The titlebar class won't hide or show like it says in the sencha docs. I'm initializing it like this

{
    xtype: 'titlebar',
    docked: 'top',
    hidden: true
};

So it starts off hidden. When I set hidden: false then it does show up. I have it referenced in a button where when the button is pressed it either shows or hides.

bar.show() and bar.hide() do not work. Neither does bar.setHidden(true) or bar.setHidden(false). Neither does bar.hidden = true or bar.hidden = false. The event handler in my button does work, I have it printing a message when it's pressed.

What's the alternative to get a titlebar to disappear and reappear?

UPDATE

Below is the code for my object and the button listener. Here is a link to the entire class file: http://pastebin.com/tbS35Czk

My settingsbar (this is defined in another class right here: http://pastebin.com/xP5NSrb8)

var settingsbar = {
                xtype: 'meterreadings_settingsbar',
                docked: 'top',
                added: false
              };

Here is the button and listener:

{
   xtype: 'mbButton',
   text: 'Settings',
   align: 'right',
   listeners: {
       tap: function(source, e, eOpts) {
            if(!settingsbar.added){
                settingsbar.added = true;
                Ext.ComponentQuery.query('.meterreadings_main')[0].add(settingsbar);
            }   
            else{
                if(settingsbar.hidden){
                    settingsbar.show();
                }
                else{
                    settingsbar.hide();
                }

            }
       }
    }
}
Was it helpful?

Solution

Solved the problem. Instead of doing

var settingsbar = {
                xtype: 'meterreadings_settingsbar',
                docked: 'top',
                added: false
              };

I needed to do

var settingsbar = Ext.create('pw.meterreadings.main.settingsbar.Settingsbar',{
                docked: 'top',
                added: false
              });

The difference is I'm using Ext.create instead of xtype.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top