Dynamically update button labels in a controlgroup

Dynamically update button labels in a controlgroup

I am trying to dynamically update the labels of two buttons in a controlgroup. The way I am doing it is updating the labels, but the controlgroup is not formed, rather two buttons appear separately side-by-side. Can anyone point me how this can be achieved?

Here is the relevant code:

  1. // Set the button texts.
  2. $("#day-slot").empty();
  3. var markUp = "<a href='#' data-role='button' data-theme='e' onclick='popMenu(true)'>" + days[1] + "</a>" +
  4.                      "<a href='#' data-role='button' data-theme='e' onclick='popMenu(false)'>" + slots[2] + "</a>";
  5. $("#day-slot").append(markUp).trigger("create");


Here is the code in action: http://jsbin.com/abofaq/2

Thanks for any pointers.