请看:http://jsbin.com/xebaxiya/3/edit
弹出工作在第一个列表视图,但点击"添加日期"后,我看不出如何让弹出工作在随后的列表视图。
任何建议吗?非常感谢
在添加动态datepicker的代码中,从内容字符串中删除class="hasDatepicker",然后在附加元素之后,在新输入上调用datepicker()函数来初始化小部件:
$("#add").click(function() {
nextId++;
if (nextId<21) {
var content = '<li class="ui-field-contain"><label for="datechosen' + nextId + '">Date ' + nextId + '</label><div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset"><input type="text" id="datechosen' + nextId + '" name="datechosen' + nextId + '" data-role="date" placeholder="Pop up doesnt work :( " readonly="readonly" /></div></li>';
$( "#set" ).append( content ).listview( "refresh" );
$("#datechosen" + nextId).datepicker();
}
});
这是你更新的jsBin