Subscribe to a playlist

Given a playlist URI, click a button to subscribe.

The Javascript

/* Instantiate the global sp object; include models */
var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
$("#subscribe").click(function(playlist){
    var playlist = models.Playlist.fromURI("spotify:user:spotify:playlist:3Yrvm5lBgnhzTYTXx2l55x");
    playlist.subscribed = true;
    playlist.observe(models.EVENT.CHANGE, function() {
        console.log("Playlist is subscribed!");
    });
});

The HTML

<input type="button" id="subscribe" value="Subscribe" />>

Live Example