I have this very simple script of jQuery plugin called blockUI
I found many posts with the same issue but no resolution
Can someone take a look at this snippet or suggest an alternative to blockUI?
Thank you!
function block() {
alert('gonna block')
$.blockUI();
setTimeout(unBlock(), 5000);
}
function unBlock() {
$.unblockUI();
}
function alertUser() {
alert('Alert User');
}
<script src=".0.0/jquery.min.js"></script>
<script src=".blockUI/2.70/jquery.blockUI.js"></script>
<button onclick="alertUser()">Alert</button>
<button onclick="block()">Block!</button>
<button onclick="unBlock()">UnBlock!</button>
I have this very simple script of jQuery plugin called blockUI
I found many posts with the same issue but no resolution
Can someone take a look at this snippet or suggest an alternative to blockUI?
Thank you!
function block() {
alert('gonna block')
$.blockUI();
setTimeout(unBlock(), 5000);
}
function unBlock() {
$.unblockUI();
}
function alertUser() {
alert('Alert User');
}
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/jquery.blockUI/2.70/jquery.blockUI.js"></script>
<button onclick="alertUser()">Alert</button>
<button onclick="block()">Block!</button>
<button onclick="unBlock()">UnBlock!</button>
Share
Improve this question
edited Feb 5, 2019 at 18:28
JavaSheriff
asked Feb 4, 2019 at 22:05
JavaSheriffJavaSheriff
7,71526 gold badges102 silver badges173 bronze badges
2 Answers
Reset to default 2You need to include jQuery before you include any plugins.
Change the order of your includes.
It does work but you are calling unblock instantly and it goes away, pass the function into setTimeout instead of calling it.
function block() {
$.blockUI();
setTimeout(unBlock, 5000);
}
function unBlock() {
$.unblockUI();
}
function alertUser() {
alert('Alert User');
}
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/jquery.blockUI/2.70/jquery.blockUI.js"></script>
<button onclick="alertUser()">Alert</button>
<button onclick="block()">Block!</button>
<button onclick="unBlock()">UnBlock!</button>