Callback in js.



  • I can't get the callback, writes. введите сюда описание изображения

    Code:

    var func = {
    

    CurrentTimeRound : 0,
    MoveTimer : function(sec, finish){

    this.CurrentTimeRound = sec;
    var timer_id = setInterval(function(){
    
      func.CurrentTimeRound--;
    
      if(func.CurrentTimeRound > 0){
    
        $('.rullet-time').removeClass("finish").children('span').text(func.CurrentTimeRound);
    
      }else{
    
        clearInterval(timer_id);
        $('.rullet-time').addClass('finish');
        finish();
    
      }
    
    }, 1000);
    

    }

    };

    Also on https://jsfiddle.net/ndthLv7n/

    Issued func.MoveTimer() in another file, first condition if performed as well as the second, but not a function finish like, callback

    Please tell me what I'm doing wrong. Thank you.



  • When calling the function func.MoveTimer It either fails to transmit the parameters, but the second parameter is not a function.

    That's why the next mistake is made.

    Func.MoveTimer()

    In such a challenge, the functions are not transferred No one. The argument, therefore, within the function both arguments will be relevant undefined

    Give arguments to function, and it'll work.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2