[英]BlockUI for a certain <div> only
I'm trying to block a div (with id="blockme") in my page that contains a gridview while the gridview is loading. 我正在尝试在加载gridview时阻止我的页面中包含gridview的div(标识为id =“ blockme”)。 I found the code below at Github but this code blocks the whole page.
我在Github上找到了下面的代码,但是此代码阻止了整个页面。
<script type="text/javascript">
Page = Sys.WebForms.PageRequestManager.getInstance();
Page.add_beginRequest(OnBeginRequest);
Page.add_endRequest(endRequest);
function OnBeginRequest(sender, args) {
$.blockUI();
}
function endRequest(sender, args) {
$.unblockUI();
}
</script>
I looked into stackoverflow and I found this answer which shows how to block a certain div on button click. 我调查了stackoverflow,发现了这个答案, 该答案显示了如何在单击按钮时阻止某个div。
My problem is that I don't want to use the button click event but use page begin request and end request instead events to block my div. 我的问题是我不想使用按钮单击事件,而是使用页面开始请求和结束请求来代替事件来阻止我的div。
I tried doing this but it doesn't work: 我尝试这样做,但是不起作用:
function OnBeginRequest(sender, args) {
$('#blockme').blockUI();
}
function endRequest(sender, args) {
$('#blockme').unblockUI();
}
These two links helped me solve it here and this SO question 这两个链接帮助我在这里解决了这个问题
Here's how it worked: 运作方式如下:
<script type="text/javascript">
Page = Sys.WebForms.PageRequestManager.getInstance();
Page.add_beginRequest(OnBeginRequest);
Page.add_endRequest(endRequest);
function OnBeginRequest(sender, args) {
$('div#blockme').block({
message: '' ,
overlayCSS: { backgroundColor: '#fff' }
});
}
function endRequest(sender, args) {
$('div#blockme').unblock();
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.