Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 生成动态列表视图_Jquery_Listview_Jquery Mobile - Fatal编程技术网

Jquery 生成动态列表视图

Jquery 生成动态列表视图,jquery,listview,jquery-mobile,Jquery,Listview,Jquery Mobile,我遵循这个示例,但我的问题是它根本不呈现页面,我只呈现一个白色页面。我不知道是什么问题,甚至我已将page.page()更改为page.trigger('create'),并尝试content.find(“:jqmData(role=listview)”).listview('refresh'),但什么都没有。问题是我在控制台中没有错误,所以我不知道我做错了什么。这是我的密码: $(document).bind("pagebeforechange", function(e, data) {

我遵循这个示例,但我的问题是它根本不呈现页面,我只呈现一个白色页面。我不知道是什么问题,甚至我已将
page.page()
更改为
page.trigger('create')
,并尝试
content.find(“:jqmData(role=listview)”).listview('refresh')
,但什么都没有。问题是我在控制台中没有错误,所以我不知道我做错了什么。这是我的密码:

$(document).bind("pagebeforechange", function(e, data) {
    console.log('[binding][pagebeforechange]');
    if( typeof data.toPage === "string") {
        var u = $.mobile.path.parseUrl(data.toPage);
        if(u.hash.search(/^#watch/) !== -1) {
            console.log('[binding] setWatch');
            var id = u.hash.replace(/.*id=/, "");
            e.preventDefault();
            setWatch(u, id);
        } else if(u.hash.search(/^#playlist/) !== -1) {
            console.log('[binding] setPlaylist');
            //Bind the change page event, and if it is playlist page, call setPlaylist
            playlistId = u.hash.replace(/.*id=/, "");
            e.preventDefault();
            setPlaylist(u);
        }
    }
});

function setPlaylist(urlObj) {
    console.log('[setPlaylist]');
    var page = $('#playlist');
    var content = $('#playlistContent');
    var html = getListHtml(playlistId); //Here a get the complete list code
    content.empty();
    content.html(html);
    console.log('[setPlaylist] before trigger');
    page.trigger('create');
    //page.page();
    //content.find(":jqmData(role=listview)").listview('refresh');
    page.listview();

    var options = {};
    options.reloadPage = true;
    options.dataUrl = urlObj.href;
    options.transition = "slide";
    $.mobile.changePage(page, options);
    console.log('[setPlaylist] changepage');
    location.hash = urlObj.hash;
}
所以如果你知道我做错了什么,请告诉我

谢谢

编辑:

如果我使用
content.find(“:jqmData(role=listview)”).listview('refresh')
它会显示下一个错误

未捕获的TypeError:无法读取属性“jQuery1640144779944140464” 未定义的


而且似乎
pagebeforechange
会触发两次。我真的不知道我做错了什么。

错误是丢失的,所以jqm找不到要更改的页面,所有的错误都是因为这个。非常感谢您对我的帮助。

您能链接到演示页面吗?也许今天是非常糟糕的一天,所以请使用以下命令:也许明天我上传到JSFIDLE或其他东西,但今天这是不可能的。使用jQM,您不使用文档。准备好了吗?我还收到了以下错误:“未捕获的TypeError:无法读取未定义的属性“jQuery16408813936458900571”我还得到了403的回复:在添加jQM库之后,您是否可以移动/js/smartphone.js?哪里缺少“,”?