Created
September 15, 2012 17:56
-
-
Save MeoMix/3729069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i = 0; i < songs.length; i++){ | |
//Wrap in a closure to preserve song index for each iteration. | |
//If you don't do this the contextmenu method will always have the last song. | |
(function(i){ | |
var listItem = $('<li/>').appendTo(songList); | |
var song = songs[i]; | |
var link = $('<a/>', { | |
id: song.id, | |
href: '#' + song.id, | |
text: song.name, | |
contextmenu: function(e){ | |
var contextMenu = new SongListContextMenu(song); | |
contextMenu.show(e.pageY, e.pageX); | |
//Prevent default context menu display. | |
return false; | |
} | |
}).appendTo(listItem); | |
}(i)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment