diff options
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 29233dec02..11886b91fe 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -1199,7 +1199,7 @@ var UIDynamicList = UIElement.extend({ 'name': this.options.name, 'value': value })]); - dl.querySelectorAll('.item, .add-item').forEach(function(item) { + dl.querySelectorAll('.item').forEach(function(item) { if (exists) return; @@ -1210,10 +1210,13 @@ var UIDynamicList = UIElement.extend({ 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); + } + dl.dispatchEvent(new CustomEvent('cbi-dynlist-change', { bubbles: true, detail: { |