A Spotify Artist Dropdown menu using Jquery-ui

May provide some help to anyone using the Spotify API:

<script type="text/javascript">
$(function() {
  $("#spotify_song_search").autocomplete({
    source: function(request, response) {
      $.get("http://ws.spotify.com/search/1/artist.json", {
//currently selected in input
q: request.term
}, function(data) {
  response($.map(data.artists.splice(0,5), function(item) {
    return {label: item.name, artist: item};
  }));
});

    },
    select: function(el, ui){
      $("#selectedId").append(ui.item.artist.href);
      $("#selectedName").append(ui.item.artist.name);
    }
  });
});

</script>


Check out a live demo here:  http://spotmybands.herokuapp.com/
Powered by Blogger.