익명 함수, 폐쇄 적 인 쓰기, js 대상 의 사례 결합

/*
 * name       :Zuoquan Tu
 * mail       :[email protected]
 * date       :2015/04/1
 * version    :1.1
 * description:modified by tuzuoquan 2015/04/7
 * CopyRight (C) 2015-04
 */
$(function() {
	//             
	$(".wrap_r-list li").click(function(event) {
		$(this).addClass('current-q').siblings().removeClass('current-q');
		//$(".tab_content > .tab_content1").hide().eq($('.wrap_r-list li').index(this)).show();
	});
	
});

var PageHandler = (function($) {
	return {
		/**
		 * @author:Zuoquan Tu 
		 * url:   url      url   pageNo:        
		 * pageRow:          
		 * targetEleId:  div id   ,                
		 * 
		 * pageNo,pageRow,url,targetEleId
		 */
		gotoPage : function(data, url, targetEleId) {
			$.ajax({
				type : 'POST',
				url : url,
				data : data,
				dataType : 'html',
				success : function(data) {
					//         ,        
					$("#" + targetEleId).children().remove();
					$("#" + targetEleId).html(data);
				},
				error : function() {
					alert("        !");
				}
			});
		}
	};
})(jQuery);

/*          */
var page2 = {
	/*
	 * pageNo:1, PageRow:12,
	 */
	data : {
		"pageNo" : 1,
		"pageRow" : 10,
		"siteCode" : siteCode,
		"taskId" : taskId
	}
};

/**
 *                   
 */
(function(pg) {
	// alert(pg.data.siteCode);
	PageHandler.gotoPage(pg.data, //        
		basePath + "/singleReject/toSiteUnreachAbleByPage", //     url
			"view-problemInfo-data" //       div   
	);
})(page2);

function loadDataSiteUnReach(){
	PageHandler.gotoPage(page2.data, //        
			basePath + "/singleReject/toSiteUnreachAbleByPage", //     url
				"view-problemInfo-data" //       div   
		);
}
/**
 *     
 * 
 * @param pageNum
 */
function gotoPage2(pageNum) {
	var pageCount = $("#view-problemInfo-data #pageCount").val();
	if (pageNum < 1) {
		page2.data.pageNo = 1;
	} else if (pageNum > pageCount) {
		page2.data.pageNo = pageCount;
	} else {
		page2.data.pageNo = pageNum;
	}
	PageHandler.gotoPage(page2.data, //        
			basePath + "/singleReject/toSiteUnreachAbleByPage", //     url
				"view-problemInfo-data" //       div   
	);
}

function confirmButton2() {
	//        
	var pageNumInput = $("#view-problemInfo-data #pageNumInput").val();
	if(pageNumInput == ""){
		alert("   ,        !");
		return;
	}
	gotoPage2(pageNumInput);
}

좋은 웹페이지 즐겨찾기