码迷,mamicode.com
首页 > Web开发 > 详细

JQuery对象函数

时间:2018-12-03 11:18:35      阅读:376      评论:0      收藏:0      [点我收藏+]

标签:efault   清空   审核   查询   search   creat   handler   ext   com   

1、JQuery对象函数写法格式

简单示例:

main代表对象名,main.roleName = (function () { return $(‘#RoleName‘).val();})();表示为对象的roleName属性赋值。

 1 $(document).ready(function () {
 2 MainManager.init();
 3 });
 4 
 5 var MainManager = window.MainManager = {};
 6 
 7 (function (main) {
 8 main.init = function () {
 9 this.roleName();
10 }
11 
12 main.roleName = (function () {
13 return $(‘#RoleName‘).val();
14 })();
15 
16 })(MainManager);

 实例:

注意下面下拉列表写法格式,有多种情况可以借鉴,

  1 $(document).ready(function () {
  2     MainManager.init();
  3 });
  4 
  5 var MainManager = window.MainManager = {};
  6 
  7 
  8 (function (main) {
  9     main.init = function () {
 10         this.bindBtnSearch();
 11         this.bindBtnClear();
 12         this.initSearchCombo();
 13         this.initGirdMain();
 14     }
 15 
 16   
 17 
 18     main.roleName = (function () {
 19         return $(‘#RoleName‘).val();
 20     })();
 21 
 22     main.commType = (function () {
 23         return $(‘#frmSearch #CommType‘).val();
 24     })();
 25 
 26 
 27     main.initSearchCombo = function () {
 28         var frmSearch = $(‘#frmSearch‘);
 29         frmSearch.find(‘#Fstatus‘).first().combobox({
 30             valueField: ‘CodeNO‘,
 31             textField: ‘CodeName‘,
 32             panelHeight: ‘auto‘,
 33             data: [
 34              { CodeNO: ‘‘, CodeName: ‘--全部--‘ },
 35              { CodeNO: 3, CodeName: ‘已保存‘ },
 36              { CodeNO: 0, CodeName: ‘待审核‘ },
 37              { CodeNO: 1, CodeName: ‘已审核‘ },
 38              { CodeNO: 2, CodeName: ‘已关闭‘ }
 39             ]
 40         });
 41 
 42         //下拉列表
 43         frmSearch.find(‘#FranchiseeNO‘).first().combotree({
 44             panelWidth: 330,
 45             panelHeight: 230,
 46             valueField: ‘id‘,
 47             textField: ‘text‘,
 48             url: ‘/v_JM_Franchisee/GetFranchiseeListData‘,
 49             onLoadSuccess: function (node, data) {
 50                 var rowCount = data.length;
 51                 if (rowCount > 0) {
 52                     $(‘#frmSearch #FranchiseeNO‘).combotree("setValue", data[0].id);
 53                 }
 54                 if ((data.length === 1) && (data[0].children == null)) {
 55                     $(‘#frmSearch #FranchiseeNO‘).combotree(‘disable‘);
 56                 };
 57             },
 58             method: ‘post‘,
 59             editable: true
 60         });
 61 
 62         frmSearch.find(‘#CityID‘).first().combobox({
 63             url: ‘/area/getCitiesEnable‘,
 64             valueField: ‘RegionID‘,
 65             textField: ‘Name‘
 66         });
 67 
 68         $("#frmSearch #DeptID").combotree({
 69             panelWidth: ‘230‘,
 70             panelHeight: ‘390‘,
 71             valueField: ‘id‘,
 72             textField: ‘text‘,
 73             url: ‘/SYS_Department/GetAllSYS_DepartmentByTree?_=‘ + (new Date()).valueOf(),
 74             editable: false
 75         });
 76     }
 77 
 78     //绑定查询按钮
 79     main.bindBtnSearch = function () {
 80         $(‘#frmSearch #btnSearch‘).bind(‘click‘, function () {
 81             if (!$("#frmSearch").form(‘validate‘)) return;
 82             main.queryGridMain(form2Json("frmSearch"));
 83         });
 84     }
 85 
 86     //绑定清空按钮
 87     main.bindBtnClear = function () {
 88         $(‘#frmSearch #btnClear‘).first().bind(‘click‘, function () {
 89             var frmSearch = $(‘#frmSearch‘);
 90             frmSearch.form(‘clear‘);
 91 
 92             var $franchiseeno = $(‘#frmSearch #FranchiseeNO‘);
 93             var $tree = $franchiseeno.combotree(‘tree‘);  // 获取数据表格对象
 94             var root = $tree.tree("getRoot");
 95             $franchiseeno.combotree(‘setValue‘, root.id);
 96            
 97             $("#frmSearch #Fstatus").combobox("setValue", "");
 98 
 99             frmSearch.find(‘#btnSearch‘).first().trigger(‘click‘);
100         });
101     }
102 
103     
104     main.initGirdMain = function () {
105         var config = Util.getBasicConfig();
106         var queryModel = form2Json("frmSearch");
107         $.extend(config, {
108             url: ‘/ReceiveContract/ReceiveContract/GetAllReceiveContract‘,
109             queryParams: queryModel,
110             sortName: "CreateDate",
111             sortOrder: "desc",
112             onDblClickRow: function (rowIndex, rowData) {
113                 MainManager.editContract();
114             },
115             columns: [
116               [
117                   {
118                       field: "Fstatus", title: "审核状态", width: 80, align: "center", sortable: true,
119                       formatter: function (value, rows) {
120                           switch (value) {
121                               case 2:
122                                   return "<strong style=‘color:darkgray;‘>已关闭</strong>";
123                               case 0:
124                                   return "<strong style=‘color:rosybrown;‘>未审核</strong>";
125                               case 1:
126                                   return "<strong style=‘color:green;‘>已审核</strong>";
127                               case 3:
128                                   return "<strong style=‘color:red;‘>已保存</strong>";
129                               default:
130                                   return "--";
131                           }
132                       }
133                   },
134 
135                   { field: "FContractNo", title: "编号", width: 90, align: "center", sortable: true }
136 
137               ]
138             ]
139         });
140         var toolList = [
141                 {
142                     id: ‘btnAdd‘, text: ‘添加‘, iconCls: ‘icon-add‘,
143                     handler: function () { MainManager.addContract(); }
144                 }
145         ];
146         config.toolbar = toolList;
147 
148         $(‘#gridMain‘).datagrid(config);
149     }
150 
151 
152     //新增
153     main.addContract = function () {
154         $(‘#winEdit‘).window({
155             height: Math.min($(window).height() * 0.9, 820),
156             onLoad: function () {
157                 EditManager.initAdd();
158             },
159             onClose: function () {
160                 delete EditManager;
161             },
162             title: ‘新增‘,
163             iconCls: ‘icon-add‘
164         });
165         $(‘#winEdit‘).window(‘center‘);
166         $(‘#winEdit‘).window(‘open‘);
167         $(‘#winEdit‘).window(‘refresh‘, ‘/ReceiveContract/ReceiveContract/EditContract?_=‘ + (new Date()).valueOf());
168     }
169 })(MainManager);

 

JQuery对象函数

标签:efault   清空   审核   查询   search   creat   handler   ext   com   

原文地址:https://www.cnblogs.com/MirZhai/p/10057120.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!