0

I am using block ui for blocking the div on button click. But after blocking i want the div should be unblocked after some delay. But in my case the div is blocking permanently. Here is my code:

<script src="jQuery 1.10.1.min.js" type="text/javascript"></script>
    <script src="blockui.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#Button1').click(function () {
                $('div#blockit').block({

                    message: '<h6>Processing</h6>',
                    css: { border: '3px solid #a00' }


                });
                setTimeout($.unblockUI, 2000); 
            });

        });

    </script>



    <div>
        <input id="Button1" type="button" value="button" />
    </div>

    <div id="blockit" style="width: 200px; height=200px;">

    </div>

I am unable to figure out why that settimeout is not working. Please give me the solution. Thanx in advance.

user2465744
  • 11
  • 1
  • 3

4 Answers4

0

try it as

setTimeout(function(){ $.unblockUI },2000)
Pradeeshnarayan
  • 1,235
  • 10
  • 21
0

try

$('#Button1').click(function () {
            $('div#blockit').block({

                message: '<h6>Processing</h6>',
                css: { border: '3px solid #a00' },
                timeout:2000

            });
            //setTimeout($.unblockUI, 2000); 
        });
Clxy
  • 505
  • 1
  • 5
  • 13
0

My guess is you're getting a JavaScript error because unblockui may use this and calling it the way you do changes this into window.

If you press F12 in a browser do you see a script error in the console?

            setTimeout(function(){
              $.unblockUI
            }, 2000); 
HMR
  • 37,593
  • 24
  • 91
  • 160
0

You have to use

$('div#blockit').unblock()

This is the difference

$('id').block() -> $('id').unblock()

$.blockUI() -> $.unblockUI()
Paul_Arg
  • 1
  • 1