平。分组工作正常,除非我尝试添加一些类别项目计数。添加此项后,项目将根据其类别停止组。有办法解决吗?
http://jsfiddle.net/smatisen/md17azga/
$('.todo-listview').on("afterRefresh", function () {
$(".ui-li-divider").each(function () {
console.log($(this).text());
var textSplit = $(this).text().split(",_#_");
var countValue = textSplit[1];
console.log(countValue);
$(this).text(textSplit[0]);
var count = document.createElement('span');
$(count).addClass('ui-li-count').text(countValue);
$(this).append(count);
});
});
$('.todo-listview').listview({
autodividers: true,
autodividersSelector: function (li) {
var out = li.data("category");
var ranomNumber = $('li[data-category="' + out + '"]').size();
if (out == "") {
return "A Table Is Not Set";
} else {
return [out, "_#_" + ranomNumber];
}
}
}).listview("refresh").trigger("afterRefresh");
答案 0 :(得分:0)
您可以使用.length而不是.size()来获取计数,而不是返回数组,只需连接字符串(return out + "_#_" + ranomNumber;
)
$('.todo-listview').listview({
autodividers: true,
autodividersSelector: function (li) {
var out = li.data("category");
var ranomNumber = $('li[data-category="' + out + '"]').length;
if (out == "") {
return "A Table Is Not Set";
} else {
return out + "_#_" + ranomNumber;
}
}
}).listview("refresh").trigger("afterRefresh");
更新了 FIDDLE