我想列出一个包含播放列表中曲目的普通列表。我有问题列出该列表中的曲目,我只是得到了字段(曲目,艺术家,时间,星级,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,但我测试改为1.30.0,同时查看API文档时它不起作用,并且查看了1.3 * .0版本。
我做错了什么?
答案 0 :(得分: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) { ...
“使用任何元字符(例如 !“#$%&amp;'()* +,。/:;&lt; =&gt;?@ [] ^`{|}〜)作为名称的字面部分,必须 用两个反斜杠逃脱:\。“ - http://api.jquery.com/category/selectors/