Question

I want to list a normal List with tracks from a playlist. i have problem to list the tracks from that list, I just get the head with the fields (track, artist, time, star, nr and more), which is the gray one. That's the only one showing up, no tracks appears and it looks very weird.

This is the function i'm using:

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();
    });
}

I'm using jQuery and Spotify's API version 1.30.0, i think it should be 1.0.0, but i tested to change to 1.30.0 while looking in the API doc when it didn't work, and view had 1.3*.0 in version.

What am I doing wrong?

Was it helpful?

Solution

The playlisturi variable contains colons, which need to be escaped with \\:

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

"To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \." - http://api.jquery.com/category/selectors/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top