动态加载collpase和listview

花了一天时间都没弄出来,突然间看到了这个,完美的解决了我的问题。通过ajax获取的信息加载collpase和listview

http://jsfiddle.net/Palestinian/VLc65/

里面的核心代码:

var data = [{
    "title": "Category 1",
        "items": [
        "one", "two", "three"]
}, {
    "title": "Category 2",
        "items": [
        "four", "five", "six"]
}, {
    "title": "Category 3",
        "items": [
        "seven", "eight", "nine", "ten"]
}];

$.each(data, function (i, v) {
    var items = v.items;
    var col = $("
", { "data-role": "collapsible" }); var title = $("

", { text: v.title }).appendTo(col); var list_items = ''; $.each(items, function (x, y) { list_items += "
  • " + y + "
  • "; }); var list = $("
      ", { "data-role": "listview", "id": "listview" + i, "data-inset": true }); $(list).append(list_items); $(list).appendTo(col); $("#stuff").append(col).collapsibleset().trigger("create"); });




    你可能感兴趣的:(jquery,mobile,jquery,mobile,collapsible,listview)