修改BUG:更新lgbDropdown方法

This commit is contained in:
Argo-MacBookPro 2018-08-05 01:19:34 +08:00
parent 1eeb406c2f
commit 7afbe56e1a
2 changed files with 13 additions and 6 deletions

View File

@ -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 {

View File

@ -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;