From: Jo-Philipp Wich Date: Wed, 14 Aug 2019 20:34:02 +0000 (+0200) Subject: luci-base: cbi.js: do not forcibly sort synamic list items X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5d2a0f17e1395a6e4ae1d23f020c4b835ff51601;p=oweals%2Fluci.git luci-base: cbi.js: do not forcibly sort synamic list items Ref: https://forum.openwrt.org/t/cannot-save-certain-fields/42738/2 Signed-off-by: Jo-Philipp Wich (backported from commit dbf83e35bb6e4d203eca917d4dfef2b270dd34ff) --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index e203c63ff..fa61cf644 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -903,7 +903,7 @@ CBIDynamicList = { 'name': dl.getAttribute('data-prefix'), 'value': value })]); - dl.querySelectorAll('.item, .add-item').forEach(function(item) { + dl.querySelectorAll('.item').forEach(function(item) { if (exists) return; @@ -911,10 +911,13 @@ CBIDynamicList = { if (hidden && hidden.value === value) exists = true; - else if (!hidden || hidden.value >= value) - exists = !!item.parentNode.insertBefore(new_item, item); }); + if (!exists) { + var ai = dl.querySelector('.add-item'); + ai.parentNode.insertBefore(new_item, ai); + } + cbi_d_update(); },