Ram Singh
Ram Singh

Reputation: 6928

How to show loader with set timeout function?

I have a function that is doing some calculation, i want to add jquery loader for some time for this, i have tried the following but it is not displaying the loader not getting why?

 function onChangeLeaveEndDate() {
    //$('.k-loading-mask').css('display', 'block !important');
    $(".k-loading-mask").show();
    setTimeout(function () {
        test();
    }, 10000);
    $('.k-loading-mask').hide();
}

did id do any wrong code in above? please help me how can i show a loader for specific period of time.

Upvotes: 2

Views: 14723

Answers (2)

Wasiq Muhammad
Wasiq Muhammad

Reputation: 3118

I think this should work out

function onChangeLeaveEndDate() {
            //$('.k-loading-mask').css('display', 'block !important');
            $(document).ready(function(){
              $(".k-loading-mask").show();
             setTimeout(function () {
                test();
            $('.k-loading-mask').hide();
             }, 10000);
            });
    }

Upvotes: 0

user5570620
user5570620

Reputation:

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
try this as:

function onChangeLeaveEndDate() {
   //$('.k-loading-mask').css('display', 'block !important');
   $(".k-loading-mask").show();
   setTimeout(function () {
      test(); 
      $('.k-loading-mask').hide();
   }, 10000);
}

Upvotes: 3

Related Questions