how to add dojox.mvc.Output to dojox.mobile.ListItem programmatically?-Collection of common programming errors

I want to add a label and value for ListItem programmatically how do i do it? I do not want to use rightText for ListItem.

     //   widgetId = "showUrl"
     dojo.empty(widgetId);

     var listItem = registry.byId(widgetId);
     if (listItem != undefined)
          listItem.destroy(true);

     listItem = new ListItem({}, widgetId);

     var labelOutput = dom.byId("urllabel");
     if (labelOutput == undefined) {
         labelOutput = dojo.create("div", {id: "urllabel"}, listItem.srcNodeRef);
     }
     console.log("labelOutput ", labelOutput);
     var output = new mvc.Output({ref: labelItem
                          }).placeAt(labelOutput);
     console.log("output ", output);
     //output.startup();

}

I tried the above code and it doesn’t show me the label url in ListItem.

  1. Just bumped into this page. In case if using Dojo 1.8 is an option – Dojo 1.8 allows to establish data binding right to dojox/mvc/ListItem’s label attribute, which is the text in ListItem, with dojox/mvc/at API. So you can do something like:

    var labelItem = new Stateful(); // dojo/Stateful
    registry.byId("li").set("label", at(labelItem, "value"));
    labelItem.set("value", "The text");