I am using jQuery and the widget Selectable to let my user select files to delete. I am appending each selection to a div to be able to see what divs I have selected. I need to comma seperate the values (ids) to be able to use it when saving.
How can I comma seperate? Is there a better way of doing this?
$("#photo_area").selectable({
cancel: 'a',
stop: function() {
var result = $("#selected").empty();
$(".ui-selected", this).each(function() {
var index = $(this).attr('id');
result.append(index);
});
}
});
There's nothing blatantly wrong with what you already have, but I think the following is a little more concise:
var ids = $(this).find(".ui-selected").map(function() {
return this.id;
}).get().join(",");