离线应用js

通过ajax得到数据,完了通过tpl_Index_List和json数据进行模板的对接,最后通过  $listview.listview('refresh');刷新列表页

$('#index_index').live("pagecreate", function() {
    var $li = "";
    var $strSubStr = "";
    var intSubNum = 0;
    var $webSite = rttophtml5mobi.website;
    var $webUrl = $webSite + '/ch9/NewsApi.ashx?act=index';
    var $listview = $(this).find('ul[data-role="listview"]');
    var $tpl_Index_List = function($p_array, $p_items) {
        if (rttophtml5mobi.utils.getParam('user_sub_str') != null) {
            $strSubStr = rttophtml5mobi.utils.getParam('user_sub_str');
            var $arrSubStr = new Array();
            $arrSubStr = $strSubStr.split(",");
            intSubNum = $arrSubStr.length - 1;
            for (var i = 0; i < $arrSubStr.length - 1; i++) {
                $.each($p_items.Table, function(index, item) {
                    if (item.news_cateid == $arrSubStr[i]) {
                        $li = '<li class="lst" data-icon="false"><a href="newscate.htm" data-ajax="false" data-catename="' + item.news_catename + '" data-id="' + item.news_cateid + '" style="margin:0px;padding:0px 0px 0px 55px"><img src="' + item.news_iconurl + '" alt="" /><h3>' + item.news_catename + '</h3></li>';
                        $p_array.push($li);
                    }
                })
            }
        } else {
            $li = '<li style="text-align:center">您还没有订阅任务类型新闻!</li>';
            $p_array.push($li);
        }
    }
    var $lst_Index_List = function() {
        $.getJSON($webUrl, {},
        function(response) {
            var li_array = [];
            $tpl_Index_List(li_array, response);
            var strTitle = '<li data-role="list-divider">我的订阅<span class="ui-li-count">' + intSubNum + '</span></li>';
            $listview.html(strTitle + li_array.join(''));
            $listview.listview('refresh');
            $listview.delegate('li a', 'click', function(e) {
                rttophtml5mobi.utils.setParam('cate_link_id', $(this).data('id'))
                rttophtml5mobi.utils.setParam('cate_link_name', $(this).data('catename'))
            })
        })
    }
    $lst_Index_List();
})