在如下的方法中 嵌套绑定 $("#btnCheck").bind("click", ParameterJson, InitPage);时候 必须使用 $("#btnCheck").unbind("click") 否则用户点击第一次,按钮执行一次该事件;用户点击第二次,按钮执行两次该事件;用户点击第N次,按钮执行N次该事件。
function InitPage() {
try {
var ResultJson = InitParameter();
if (!ResultJson.Result) {
alert(ResultJson.ErrorMessage);
return false;
}
var ParameterJson = { pageUrl: strPageUrl, thWidth: strThWidth, divData: strDivData, divButton: strDivButton, QueryConditions: strQueryConditions };
//初始化翻页按钮行
ResultJson = PageButton(strPageUrl, strDivButton, strQueryConditions);
if (!ResultJson.Result) {
alert(ResultJson.ErrorMessage);
return false;
}
if (!FirstPage(ParameterJson)) {
alert("页面初始化失败!");
return false;
}
//为“查询”按钮绑定事件
$("#btnCheck").unbind("click");
$("#btnCheck").bind("click", ParameterJson, InitPage);
//为“首页”按钮绑定事件
$("#spanFirstPage").bind("click", ParameterJson, FirstPage);
//为“前一页”按钮绑定事件
$("#imgPrePage").bind("click", ParameterJson, PrePage);
//为“下一页”按钮绑定事件
$("#imgNextPage").bind("click", ParameterJson, NexPage);
//为“最后一页”按钮绑定事件
$("#spanEndPage").bind("click", ParameterJson, EndPage);
//为“跳转”按钮绑定事件
$("#imgGo").bind("click", ParameterJson, GoPage);
return true;
}
catch (ex) {
alert("页面初始化失败!");
}
}