From 7afbe56e1a6c47963a89db53bec52108f26608f4 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Sun, 5 Aug 2018 01:19:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0lgbDropdown=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/wwwroot/js/Longbow.Common.js | 6 ++++-- Bootstrap.Admin/wwwroot/js/longbow.dataentity.js | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Bootstrap.Admin/wwwroot/js/Longbow.Common.js b/Bootstrap.Admin/wwwroot/js/Longbow.Common.js index bf652958..cd763c1e 100644 --- a/Bootstrap.Admin/wwwroot/js/Longbow.Common.js +++ b/Bootstrap.Admin/wwwroot/js/Longbow.Common.js @@ -359,9 +359,11 @@ var op = typeof options === 'object' && options; if (/val/.test(options)) { if (arguments.length === 1) - return $this.first().children('button').attr("data-val"); + return $this.find('[data-toggle="dropdown"').attr("data-val"); else { - $this.first().children(':first').children(':first').text($this.find('[data-val="' + arguments[1] + '"]').text()); + var $element = $this.find('[data-toggle="dropdown"]'); + $element.text($this.find('[data-val="' + arguments[1] + '"]').text()); + $element.attr('data-val', arguments[1]); } } else { diff --git a/Bootstrap.Admin/wwwroot/js/longbow.dataentity.js b/Bootstrap.Admin/wwwroot/js/longbow.dataentity.js index 04ceaa30..a7cca990 100644 --- a/Bootstrap.Admin/wwwroot/js/longbow.dataentity.js +++ b/Bootstrap.Admin/wwwroot/js/longbow.dataentity.js @@ -11,15 +11,16 @@ load: function (value) { for (name in this.options.map) { var ctl = $("#" + this.options.map[name]); - ctl.val(value[name]); if (ctl.attr('data-toggle') == "dropdown") { var val = value[name]; if ((typeof val == "string" && val == "") || val == undefined) val = ctl.attr('data-default-val'); - ctl.children(':first').text(ctl.next().find('[data-val="' + val + '"]').text()); + ctl.text(ctl.parent().find('.dropdown-menu [data-val="' + val + '"]').text()); + ctl.attr('data-val', val); } else if (ctl.attr('data-toggle') == 'toggle') { ctl.bootstrapToggle(value[name] ? 'on' : 'off'); } + else ctl.val(value[name]); } }, reset: function () { @@ -27,13 +28,13 @@ var ctl = $("#" + this.options.map[name]); var dv = ctl.attr("data-default-val"); if (dv === undefined) dv = ""; - ctl.val(dv); if (ctl.attr('data-toggle') == "dropdown") { - ctl.children(':first').text(ctl.next().find('[data-val="' + dv + '"]').text()); + ctl.text(ctl.parent().find('.dropdown-menu [data-val="' + dv + '"]').text()); } else if (ctl.attr('data-toggle') == 'toggle') { ctl.bootstrapToggle(dv == "true" ? 'on' : 'off'); } + else ctl.val(dv); } }, get: function () { @@ -45,6 +46,10 @@ target[name] = ctl.prop('checked'); continue; } + else if (ctl.attr('data-toggle') == 'dropdown') { + target[name] = ctl.attr('data-val'); + continue; + } else if (dv != undefined && ctl.val() == "") target[name] = dv; else target[name] = ctl.val(); if (target[name] == "true" || target[name] == "True") target[name] = true;