ILikeOnDisplayPlaylist

From iLike

Jump to: navigation, search

The script command iLikeOnDisplayPlaylist() is an optional script function to be provided by a developer's page which invokes the iLikeDisplayPlaylist command. Each time the playlist is rendered (e.g. on initial display, after adding a song, removing a song, re-ordering, etc) this method will be called with a data object containing the following named values: playlistName, editMode, numSongs, and context.

You may receive callbacks to the function of your choice by passing it to iLikeDisplayPlaylist in the onDisplay parameter.

The point of this function is that it gives a developer the ability to hide or show different parts of the page if the playlist is short or long, depending on the number of songs.

Parameters

  • playlistName - the name of the playlist that was just rendered or re-rendered
  • editMode - the mode of the playlist display - either "edit", "view", or "add"
  • numSongs - the number of songs displayed in the playlist
  • context - the context in which the playlist is being rendered - values are "onLoad", "onAdd", "onUpdate", "onDone", "onEdit", "onMoveToTop", or "onRemove"

Usage

Note that implementing this callback function is optional. It offers developers more control in how to present UI and when to show/hide sections. Below is an example of how this could be used.

<div id="debug_name" />
<div id="debug_mode" />
<div id="debug_num_songs" />

function iLikeOnDisplayPlaylist(data) {
  document.getElementById("debug_name").setTextValue("playlistName:\"" + data.playlistName + "\");
  document.getElementById("debug_mode").setTextValue("editMode:\"" + data.editMode + "\");
  document.getElementById("debug_num_songs").setTextValue("numSongs:" + data.numSongs);
}

Related pages