From ede9868d1b8a60686e24927be8b863f613e0221b Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Mon, 24 Oct 2016 19:12:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8idEvents=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=88=B0=E6=A1=86=E6=9E=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Content/js/framework.js | 14 ++++++++++++++ Bootstrap.Admin/Scripts/Users.js | 13 ++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 8d4b152e..6a26ae40 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -48,6 +48,20 @@ BootstrapAdmin.prototype = { constructor: BootstrapAdmin, + idEvents: function () { + var op = { + dataEntity: this.options.dataEntity, + table: this.options.bootstrapTable, + modal: this.options.modal + }; + return { + 'click .edit': function (e, value, row, index) { + op.dataEntity.load(row); + $('#' + op.table).bootstrapTable('uncheckAll').bootstrapTable('check', index); + $('#' + op.modal).modal("show"); + } + } + }, query: function () { if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh'); diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js index 37379c58..4f04617f 100644 --- a/Bootstrap.Admin/Scripts/Users.js +++ b/Bootstrap.Admin/Scripts/Users.js @@ -8,7 +8,7 @@ } }); - var extender = new BootstrapAdmin({ + var bsa = new BootstrapAdmin({ url: '../api/Users', dataEntity: dataEntity, click: { @@ -20,21 +20,12 @@ } }); - idEvents = { - 'click .edit': function (e, value, row, index) { - dataEntity.load(row); - $('table').bootstrapTable('uncheckAll'); - $('table').bootstrapTable('check', index); - $("#dialogNew").modal("show"); - } - }; - $('table').smartTable({ url: '../api/Users', //请求后台的URL(*) sortName: 'UserName', queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val() }); }, //传递参数(*) columns: [{ checkbox: true }, - { title: "Id", field: "ID", events: idEvents, formatter: BootstrapAdmin.idFormatter }, + { title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "用户名称", field: "UserName", sortable: true } ] });