增加Boolean类型数据支持

This commit is contained in:
Argo-Lenovo 2017-03-13 23:17:25 +08:00
parent 431bf4b3ed
commit 08c803b872
1 changed files with 4 additions and 2 deletions

View File

@ -14,7 +14,7 @@
ctl.val(value[name]); ctl.val(value[name]);
if (ctl.attr('data-toggle') == "dropdown") { if (ctl.attr('data-toggle') == "dropdown") {
var val = value[name]; var val = value[name];
if (!val) val = ctl.attr('data-default-val'); 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.children(':first').text(ctl.next().find('[data-val="' + val + '"]').text());
} }
} }
@ -35,8 +35,10 @@
for (name in this.options.map) { for (name in this.options.map) {
var ctl = $("#" + this.options.map[name]); var ctl = $("#" + this.options.map[name]);
var dv = ctl.attr('data-default-val'); var dv = ctl.attr('data-default-val');
if (dv !== undefined && ctl.val().trim() === "") target[name] = dv; if (dv != undefined && ctl.val() == "") target[name] = dv;
else target[name] = ctl.val(); else target[name] = ctl.val();
if (target[name] == "true" || target[name] == "True") target[name] = true;
if (target[name] == "false" || target[name] == "False") target[name] = false;
} }
return target; return target;
} }