Skip to content

Instantly share code, notes, and snippets.

@mnutt
Created May 18, 2009 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnutt/113686 to your computer and use it in GitHub Desktop.
Save mnutt/113686 to your computer and use it in GitHub Desktop.
$.fn.updateList = function(playlist) {
var items = itemsFromPlaylist(playlist);
var headers = commonHeaders(items);
for(var i in playlist.files) {
var innerHtml = "";
for(var j in headers) {
innerHtml += "<td class='"+headers[j]+"'>" + (state.library[playlist.files[i]][headers[j]] || '') + "</td>";
}
var newRow = $('<tr id="'+playlist.name+'_'+playlist.files[i]+'"><td><input type="checkbox" value="' + playlist.files[i] + '" /></td>' + innerHtml + "&nbsp;</tr>").data('idx', playlist.files[i]);
$(this).append(newRow);
}
$(this).find('tbody').selectable({filter: 'tr'});
$(this).find('tr').draggable({
filter: 'ui-selected',
cursorAt: { left: 5, top: 5 },
tolerance: 'pointer',
addClasses: false,
revert: 'invalid',
helper: function(e) {
return $("<div class='dragging'></div>").prepend($('<div style="display: none" class="add">&nbsp;</div>'))
.prepend($(e.currentTarget).parent().find('> .ui-selected').clone());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment