; (function ($, widown, document, undefined) { var naviJudgeHelper = function (ele, opt) { this.$element = ele, this.defaults = { url: "", //导航的url divId: "", //层的id proposal: "", //建议书id flag: false,// s是否跳转 judgeNewOrOld: function () { } //判断新旧值方法 } this.operation = $.extend({}, defaults, opt); }; //定义一个新就旧值判断的方法 naviJudgeHelper.prototype = { judgeDefaults: function () { var judgebool = false;//给与判断 var oldVal = ""; var newVal = ""; var columns = new Array();//记录被修改的控件名 // var flag = false; $("#" + operation.divId + " input[type='text']").not(".disabled").not(".b-gray").each(function () { newVal = $.trim($(this).val()); oldVal = $(this).attr("defaultVal"); if (oldVal == undefined) { oldVal = ""; } if (newVal != oldVal) { judgebool = true; return false; } }); $("#" + operation.divId + " select").not(".disabled").not(".b-gray").each(function () { newVal = $.trim($(this).val()); oldVal = $(this).attr("defaultVal"); if (oldVal == undefined) { oldVal = ""; } if (newVal != oldVal) { judgebool = true; return false; } }); $("#" + operation.divId + " textarea[field='textarea']").not(".disabled").not(".b-gray").each(function () { newVal = $.trim($(this).val()); oldVal = $(this).attr("defaultVal"); if (oldVal == undefined) { oldVal = ""; } if (newVal != oldVal) { judgebool = true; return false; } }); if (judgebool) { navFinancePage(); return false; } else { window.location.href = operation.url; // "/Student/" + NavPage + "/Index" + hdParam; } } }; //私有跳转方法 naviJudgeHelper.prototype = { navigatePage: function () { dialogHelper.Confirm({ content: "当前页面内容未保存,是否继续退出?", success: function () { window.location.href = operation.url; // "/Student/" + page + "/Index" + hdParam; // eval(func); }, cancle: function () { // eval(func); } }); } }; $.fn.navigateJudge = function (options) { var navi = new naviJudgeHelper(this, options); return navi.judgeDefaults(); } })(jQuery, window, document);