本文介绍了单击可折叠集合时获得计数气泡值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可折叠的集合和列表视图,它是动态创建的.在我的可折叠set元素中,我正在显示计数泡沫值.
I have a collapsible set and listview which is created dynamically. in my collapsible set element i am displayind the countbubble value.
这就是我的做法.
count = resultset.rows.length;
$(list).remove();
$.each(resultset.rows,function(index){
var row = resultset.rows.item(index);
var li = '<li><a href="#">'+row['Date']+'</a></li>';
list.append(li);
});
div = '<div data-role="collapsible" data-inset="false" data-iconpos="right" data-collapsible="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d"><h3>'+
row1["name"]+'<span class="ui-li-count ui-btn-up-c ui-btn-corner-all" data-iconpos="right">'+count+'</span></h3></div>';
}
list.appendTo(div).parent().appendTo('[data-role="content"]').end().trigger("create");
$('div[data-role="collapsible"]').collapsible({theme:'b',refresh:true});
$('[data-role="listview"]').listview().listview('refresh');
}
我能够获得点击了哪个可折叠元素,这就是我正在做的可折叠元素
I am able to get the on which collapsible element i have clicked, this is what i am doing to get collapsible element
$(document).on("expand", "div[data-role=collapsible-set] div[data-role=collapsible]", function(){
var title = $(this).find(".ui-btn-text")
.contents()
.filter(function(){
return this.nodeType == 3;
}).text();
alert("Expanded: " + title);
});
但是使用上述方法,我只能获得可折叠的元素名称.我如何获得计数泡沫的价值?
But with the above method i am able to get only collapsible element name.how can i get the value of the count bubble?
谢谢:)
推荐答案
尝试
$(document).on("expand", "div[data-role=collapsible-set] div[data-role=collapsible]", function(){
var $item = $(this).find(".ui-btn-text");
var title = $item.contents()
.filter(function(){return this.nodeType == 3;})
.text();
var count = $item.find(".ui-li-count").text();
alert("Expanded: " + title + ' count: ' + count);
});
jsFiddle
这篇关于单击可折叠集合时获得计数气泡值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!