summaryrefslogtreecommitdiff
path: root/luci2/htdocs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-02-01 18:01:49 +0000
committerJo-Philipp Wich <jow@openwrt.org>2014-02-01 18:01:49 +0000
commit4bb42cc51fbf15038be9548c002c3a3d6b2a296f (patch)
treee7396fe6164a81c5d4653e8d3ed1759c68c9c823 /luci2/htdocs
parent8f18cd5ef6869ab434fbe0fb002cb97fd34d3543 (diff)
downloadluci2-ui-4bb42cc51fbf15038be9548c002c3a3d6b2a296f.tar.gz
luci2: Properly handle empty values in ListValue widgets
Diffstat (limited to 'luci2/htdocs')
-rw-r--r--luci2/htdocs/luci2/luci2.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js
index 00365ae..45584e7 100644
--- a/luci2/htdocs/luci2/luci2.js
+++ b/luci2/htdocs/luci2/luci2.js
@@ -5489,7 +5489,7 @@ function LuCI2()
var s = $('<select />')
.addClass('form-control');
- if (this.options.optional)
+ if (this.options.optional && !this.has_empty)
$('<option />')
.attr('value', '')
.text(_luci2.tr('-- Please choose --'))
@@ -5512,6 +5512,9 @@ function LuCI2()
if (!this.choices)
this.choices = [ ];
+ if (k == '')
+ this.has_empty = true;
+
this.choices.push([k, v || k]);
return this;
}
@@ -5586,10 +5589,7 @@ function LuCI2()
{
ev.data.select.hide();
ev.data.input.show().focus();
-
- var v = ev.data.input.val();
- ev.data.input.val(' ');
- ev.data.input.val(v);
+ ev.data.input.val('');
}
else if (self.options.optional && s.selectedIndex == 0)
{
@@ -5599,6 +5599,8 @@ function LuCI2()
{
ev.data.input.val(ev.data.select.val());
}
+
+ ev.stopPropagation();
},
_blur: function(ev)
@@ -5609,7 +5611,7 @@ function LuCI2()
ev.data.select.empty();
- if (self.options.optional)
+ if (self.options.optional && !self.has_empty)
$('<option />')
.attr('value', '')
.text(_luci2.tr('-- please choose --'))
@@ -5639,7 +5641,7 @@ function LuCI2()
.appendTo(ev.data.select);
ev.data.input.hide();
- ev.data.select.val(val).show().focus();
+ ev.data.select.val(val).show().blur();
},
_enter: function(ev)
@@ -5686,6 +5688,9 @@ function LuCI2()
if (!this.choices)
this.choices = [ ];
+ if (k == '')
+ this.has_empty = true;
+
this.choices.push([k, v || k]);
return this;
},