TWebListControl - Badges on list items

Hello,
I tried creating list badges like explained here : https://www.tmssoftware.com/site/blog.asp?post=473 but they never appear.

with this simplified code (i really simplified it to this) :

for i := 0 to aList.Length-1 do
begin
  li := WbLstControl.Items.Add;
  li.ItemClassName := 'list-group-item list-group-item-info';
  li.Text := string(JS.TJSObject(aList)['Name']);
  with TWebBadge.Create(WbLstControl) do
  begin
    ElementClassName:= 'badge badge-info';
    Text := JS.toString(i);
    ParentElement := TJSHTMLElement(li.ListElement);
  end;
end;

Of course, i tried TWebBadge.Create with None, Self, list item li, the TWebListControl instance...
List items are created, badges are created but with no text and are never attached to the dom.
The badged code section is compiled to this :

var $with3 = pas["WEBLib.ExtCtrls"].TBadge.$create("Create$1",[$Self.WbLstControl]);
$with3.SetElementClassName("badge badge-info");
$with3.SetText(pas.JS.ToString(I));
$with3.SetParentElement(li.FListElement);

of course at first i tried with
aBadge := TWebBadge.Create(WbLstControl);
aBadge.ElementClassName:= 'badge badge-info';
aBadge.Text := JS.toString(i);
aBadge.ParentElement := TJSHTMLElement(li.ListElement);

Try to first add all items and after the loop of adding all items, perform adding of the badges.

Thank you, it does work like this.

But if later I need to add another line, all the badges are removed again...in pure Javascript it obviously doesn't work like this...

Known shortcoming. When you build the list, the list should be built-in its entirety.

We'll look if we can improve that with leaving previously added badges.



That would be an appreciated evolution ^^

Thank you.