luci-base: cbi: prevent unintended focus on combobox init
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
5eaf4cc489
commit
2bd428ad8a
1 changed files with 8 additions and 5 deletions
|
@ -545,7 +545,7 @@ function cbi_bind(obj, type, callback, mode) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cbi_combobox(id, values, def, man) {
|
function cbi_combobox(id, values, def, man, focus) {
|
||||||
var selid = "cbi.combobox." + id;
|
var selid = "cbi.combobox." + id;
|
||||||
if (document.getElementById(selid)) {
|
if (document.getElementById(selid)) {
|
||||||
return
|
return
|
||||||
|
@ -605,6 +605,7 @@ function cbi_combobox(id, values, def, man) {
|
||||||
cbi_bind(sel, "change", function() {
|
cbi_bind(sel, "change", function() {
|
||||||
if (sel.selectedIndex == sel.options.length - 1) {
|
if (sel.selectedIndex == sel.options.length - 1) {
|
||||||
obj.style.display = "inline";
|
obj.style.display = "inline";
|
||||||
|
sel.blur();
|
||||||
sel.parentNode.removeChild(sel);
|
sel.parentNode.removeChild(sel);
|
||||||
obj.focus();
|
obj.focus();
|
||||||
} else {
|
} else {
|
||||||
|
@ -619,16 +620,18 @@ function cbi_combobox(id, values, def, man) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Retrigger validation in select
|
// Retrigger validation in select
|
||||||
|
if (focus) {
|
||||||
sel.focus();
|
sel.focus();
|
||||||
sel.blur();
|
sel.blur();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cbi_combobox_init(id, values, def, man) {
|
function cbi_combobox_init(id, values, def, man) {
|
||||||
var obj = document.getElementById(id);
|
var obj = document.getElementById(id);
|
||||||
cbi_bind(obj, "blur", function() {
|
cbi_bind(obj, "blur", function() {
|
||||||
cbi_combobox(id, values, def, man)
|
cbi_combobox(id, values, def, man, true);
|
||||||
});
|
});
|
||||||
cbi_combobox(id, values, def, man);
|
cbi_combobox(id, values, def, man, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cbi_filebrowser(id, url, defpath) {
|
function cbi_filebrowser(id, url, defpath) {
|
||||||
|
|
Loading…
Reference in a new issue