2

i've set a timer in status bar. but the problem is that when i close the window , it finds error. how do i close the window without any error in extjs 4 .........

here is my view. it works

    var  clock = Ext.create('Ext.toolbar.TextItem', { text: Ext.Date.format(new Date(), 'g:i:s A')}),   


    this. bbar= Ext.create('Ext.ux.StatusBar', {
        id: 'win-statusbar',
        topBorder:false,
        text:'Status',
        defaultIconCls: 'info',
        defaultText: 'Status',
        items: [clock]
        });

     this.listeners= {
        render: {
            fn: function(){                 
            var task= Ext.TaskManager.start({
                 run: function(){
                     Ext.fly(clock.getEl()).update(Ext.Date.format(new Date(), 'g:i:s A'));
                 },
                 interval: 1000
             });
           }
        }
    };

controller. how to set ' Ext.TaskManager.stop()' here before close the window.

doClose: function (button) {
    var win = button.up('window');
    win.close();
}

errors

Ext.fly(clock.getEl()) is null 
Reimius
  • 5,694
  • 5
  • 24
  • 42
Zakaria Imtiaz
  • 539
  • 5
  • 17

2 Answers2

4

at last i solve it . i just execute an operation by clicking close button.

 this.listeners= {
        render: {
            fn: function(){                 
            var task= Ext.TaskManager.start({
                 run: function(){
                     Ext.fly(clock.getEl()).update(Ext.Date.format(new Date(), 'g:i:s A'));
                 },
                 interval: 1000
             });

             Ext.get('stop').on('click', function() {  //by close button id= 'stop'
                  Ext.TaskManager.stop(task);            
             }); 
           }
        }
    };
Zakaria Imtiaz
  • 539
  • 5
  • 17
3

This would work.

this.listeners= {
        render: {
            fn: function(){                 
            var task= Ext.TaskManager.start({
                 run: function(){
                     if(!Ext.fly(clock.getEl()))
                        Ext.TaskManager.stop(task);
                     Ext.fly(clock.getEl()).update(Ext.Date.format(new Date(), 'g:i:s A'));
                 },
                 interval: 1000
             });
           }
        }
    };
Reimius
  • 5,694
  • 5
  • 24
  • 42