1. #1
    Sencha User
    Join Date
    Nov 2009
    Location
    Napoli (Italy)
    Posts
    65
    Vote Rating
    0
    luca.santaniello is on a distinguished road

      0  

    Question Schedule method call with setTimeout

    Schedule method call with setTimeout


    Hi,

    I want to simulate setTimeout() function. it receives global function name. I must pass to setTimeout my method name of Ext object...

    Example:

    Code:
    RefreshLayersComponent = Ext.extend(Ext.FormPanel, 
    {
        id: 'RefreshLayersComponent',
        
        constructor: function(config) 
        {
            ...
            ...
        },
        
        afterRender: function()
        {
            RefreshLayersComponent.superclass.afterRender.apply(this, arguments);
            
            this.autoRefresh();
        },
    
        refresh: function()
        {
            ...
            ... 
        },
        
        autoRefresh: function()
        {
            this.refresh();
            setTimeout("this.autoRefresh()", 3000);
        }
    });
    setTimeout("this.autoRefresh()", 3000); run first time but then it generate error...

    Error is: this.autoRefresh is not a function

    Can you help me please?

    Thanks in advance

    Luca

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    82
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    That is because setTimeout executes in the 'window' scope.

    You want:
    Code:
    Ext.TaskMgr.start({
      run: this.refresh,
      scope: this,
      interval: 3000
    });

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    211
    Vote Rating
    0
    hieu79vn is an unknown quantity at this point

      0  

    Default


    Hi,

    I tried to catch the onclose event of popup by Ext.TaskManager but i doesnt run. Could you tell me what is the problem in my code?
    Thank you
    Code:
    createEditor: function(){
                this.editor = Ext.create('widget.texteditor',{
                    height: 200
                });
                var toolbar = this.editor.getToolbar();
                    toolbar.add({
                      iconCls: 'icon-attachment',
                      scope: this,
                      handler: function() { 
                        var myWindow = window.open('<%=PopupUrl(.....................'); 
                        this.pollForWindowClosure(myWindow);
                      }
                });
                return this.editor;
            },
            pollForWindowClosure: function(myWindow){
                if (myWindow.closed){
                    this.myFunc();
                    return;
                }
                //setTimeout(function(){this.pollForWindowClosure(myWindow)}, 10);
                Ext.TaskManager.start({
                  //run: this.refresh,
                  run: function(){this.pollForWindowClosure(myWindow)},
                  scope: this,
                  interval: 10
                });
            },
            myFunc: function(){
                alert('789');
            },

Similar Threads

  1. Help me call a method please.
    By Elijah in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 14 Dec 2009, 6:58 AM
  2. call java method from XTemplate
    By friedc in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 21 Apr 2009, 7:21 AM
  3. Call a method within a method
    By Padster in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 20 Aug 2008, 8:24 AM
  4. How to call Java method using EXTJS
    By naveen namburi in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 31 Mar 2008, 10:23 PM

Thread Participants: 2