From 5d2a0f17e1395a6e4ae1d23f020c4b835ff51601 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 14 Aug 2019 22:34:02 +0200 Subject: [PATCH] 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) --- modules/luci-base/htdocs/luci-static/resources/cbi.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(); }, -- 2.25.1