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 } ] });