【发布时间】:2015-03-06 21:58:08
【问题描述】:
JQuery(在我的 webform 的 head 函数中):
function DoThisEM() {
centerPopupEM();
loadPopupEM();
}
function DoThatEM() {
disablePopupEM();
}
var popupStatusEM = 0;
//loading popup with jQuery magic!
function loadPopupEM() {
//loads popup only if it is disabled
if (popupStatusEM == 0) {
$("#backgroundPopupEM").css({
"opacity": "0.7"
});
$("#backgroundPopupEM").fadeIn("slow");
$("#popupContactEM").fadeIn("slow");
popupStatusEM = 1;
}
}
//disabling popup with jQuery magic!
function disablePopupEM() {
//disables popup only if it is enabled
if (popupStatusEM == 1) {
$("#backgroundPopupEM").fadeOut("slow");
$("#popupContactEM").fadeOut("slow");
popupStatusEM = 0;
}
}
//centering popup
function centerPopupEM() {
//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popupContactEM").height();
var popupWidth = $("#popupContactEM").width();
//centering
$("#popupContactEM").css({
"position": "absolute",
"top": windowHeight / 2 - popupHeight / 2,
"left": windowWidth / 2 - popupWidth / 2
});
//only need force for IE6
$("#backgroundPopupEM").css({
"height": windowHeight
});
}
$("body").on('click', "#popupContactCloseEM", function (e) {
//e.preventDefault();
alert('popupContactCloseEM');
disablePopupEM();
});
$("body").on('click', "#backgroundPopupEM", function (e) {
//e.preventDefault();
alert('backgroundPopupEM');
disablePopupEM();
});
网格视图:
弹出窗口(点击任何edit 图标时:
我不知道为什么,但是当我点击x 或弹出窗口周围的背景时,不会调用disablePopupEM 函数来关闭它。我什至添加了一个测试alert,但我也没有看到。
请帮我解决问题。
【问题讨论】:
-
按 control+shift+i 时控制台中是否有任何错误?
-
我认为应该是
Page.GetType()而不是typeof(Page) -
看看这个链接中页面底部的这个例子,个人如何注册脚本以及调用关闭方法forums.asp.net/t/…
-
@MethodMan
typeof(page)一定成功了,我还在 document.ready 中添加了它们。谢谢。 -
这是一个简单的疏忽,很多人都忽略了我过去遇到同样的问题时已经挠了几次头,但是当我看到你的代码时,我花了几分钟才看到再次...很高兴我能迅速帮助您解决问题。
标签: javascript c# jquery asp.net gridview