javascript - jquery block ui getting $.blockUI is not a function - Stack Overflow

I have this very simple script of jQuery plugin called blockUII found many posts with the same issue b

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
Add a ment  | 

2 Answers 2

Reset to default 2

You 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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745212284a4616914.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信