0

我想列出一个包含播放列表中曲目的普通列表。我在列出该列表中的曲目时遇到问题,我只是用字段(曲目,艺术家,时间,明星,nr 等)获得头部,这是灰色的。这是唯一出现的一个,没有任何轨道出现,看起来很奇怪。

这是我正在使用的功能:

function setPlaylistWithTopic(playlisturi, row) {
    // Play multiple tracks
    console.log(playlisturi);

    models.Playlist.fromURI(playlisturi).load(['name','owner', 'tracks', 'description']).done(function(playlist) {
        console.log("came in");
        console.log(playlist);
        var multiple_tracks_player = document.getElementById(row);
        multiple_tracks_player.className = multiple_tracks_player.className + " sp-list-style-rounded albumlist";

        console.log(playlist);

        var list = List.forPlaylist(playlist);

        var image = Image.forPlaylist(playlist, {width: 65, height: 65});

        var playlistname = playlist.name;
        var playlistowner = playlist.owner;
        if(playlistname.length > 75) {
            playlistname=playlistname.substr(0,75) + "..";
        }
        $("#"+row).append("<div class='col-md-12 col-sm-12 col-xs-12 row'><div class='pull-left' id='albumcover'></div><div class='albumhead' id='"+playlisturi+"'><h3><a href='"+playlisturi+"'>"+playlistname+"</a></h3><span class='label col-md-12 row'>"+playlistowner+"</span></div></div>").append(list.node);
        $("#"+row + " #albumcover").append(image.node);
        $("#"+row + " .albumhead").append("<button class='sp-button sp-add-to-collection-button sp-button-accentuated-positive sp-button-accentuated' style='min-width: 156.15625px;'><span class='sp-button-text'><div class='sp-button-icon sp-icon-add'></div>Subscribe</span><span class='sp-button-background'></span></button>");
        $("#"+row + " #"+playlisturi+" .sp-add-to-collection-button").die("click");
        $("#"+row + " #"+playlisturi+" .sp-add-to-collection-button").live('click',function(e){
                //Subscribe on playlist
                e.preventDefault();
        });

        list.init();
    });
}

我正在使用 jQuery 和 Spotify 的 API 版本 1.30.0,我认为它应该是 1.0.0,但我在 API 文档不起作用时测试更改为 1.30.0,并且视图有 1.3*。 0 版本。

我究竟做错了什么?

4

1 回答 1

0

playlisturi变量包含冒号,需要用\\ 进行转义:

var escapedPlaylistUri = playlisturi.replace(":","\\:");
$("#" + row + " #" + escapedPlaylistUri + " .sp-add-to-collection-button").die("click");
$("#" + row + " #" + escapedPlaylistUri + " .sp-add-to-collectionbutton").live('click', function(e) { ...

“要使用任何元字符(例如 !"#$%&'()*+,./:;<=>?@[]^`{|}~ )作为名称的文字部分,它必须用两个反斜杠转义:\。” - http://api.jquery.com/category/selectors/

于 2013-10-30T10:53:53.860 回答