Aikau sleep wait method

cancel
Showing results for 
Search instead for 
Did you mean: 
redraccoon
Established Member

Aikau sleep wait method

Jump to solution

Hello 

I would like to have a sleep method in my aikau widget

navigateTo : function com_widget__navigateTo(urlToGo){
console.log(this);
setTimeout(function() {

                                 this.myMethod();

                                 console.log(this);
                                 },1000) ;

}

********************************************

but it's not working, I have an error that say "this.myMethod doesn't exist"

It's not working only when I call my method inside the setTimeout function ... so as you can see I put two console.log(this) to see the problem, and they are not related to the same "this" wich I don't understand

the object is "this" in the widget and the window is "this" inside the method

1 Solution

Accepted Solutions
redraccoon
Established Member

Re: Aikau sleep wait method

Jump to solution

navigateTo : function com_widget__navigateTo(urlToGo){

      var aikauThis = this;
      console.log(this);
      setTimeout(function() {
      aikauThis.alfServicePublish("ALF_NAVIGATE_TO_PAGE", {
            url: urlToGo
      });
},3000) ;

}

View solution in original post

1 Reply
redraccoon
Established Member

Re: Aikau sleep wait method

Jump to solution

navigateTo : function com_widget__navigateTo(urlToGo){

      var aikauThis = this;
      console.log(this);
      setTimeout(function() {
      aikauThis.alfServicePublish("ALF_NAVIGATE_TO_PAGE", {
            url: urlToGo
      });
},3000) ;

}