If you are using the loop index as a closure variable for a click handler being defined in the loop ... that isn't going to work. (see JavaScript closure inside loops – simple practical example for example)
I find it easier to just add the id to the ListItem and then use the event to find the item in a single click handler:
function listItemHandler(event) {
// Look up the clicked ListItem and get its id
var id = dijit.registry
.getEnclosingWidget(event.currentTarget).id;
alert(id);
}
var dlist = dijit.registry.byId("dataList");
for ( var i = 1; i <= 3; i++) {
var lstId = "list" + i;
var list = new dojox.mobile.ListItem({
label : "label" + lstId,
rightIcon : "mblDomButtonBlueCircleArrow",
transition : "slide",
id : lstId,
moveTo : "#"
});
dlist.addChild(list);
}
dojo.query("#dataList .mblListItem").on("click", listItemHandler);