getting the count bubble value upon clicking on collapsible set

与世无争的帅哥 提交于 2019-12-24 22:34:51

问题


I have a collapsible set and listview which is created dynamically. in my collapsible set element i am displayind the countbubble value.

this is how i am doing.

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?

Thanks:)


回答1:


Try

$(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



来源:https://stackoverflow.com/questions/16578287/getting-the-count-bubble-value-upon-clicking-on-collapsible-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!