johnny / johnny/jquery-sortable
empty list
- Dominant language
- HTML
- Stars
- 1.5k
- Forks
- 429
- PR merge metrics
- No merged PRs in 30d
Description
I'm having some difficulty modifying the list container (ul) when it's been emptied or loaded empty. For example, If you have two containers:
- collection list to drag from that always contains a few items.
- destination list which loads empty (unless it is being edited and it will contain some list items but can be emptied by dragging them out of there
The empty container (ul) should display a message (i.e. nothing here) whenever it loads empty or it gets emptied on edit
I tried several approaches with no avail.
```
Drag and drop an item from the list
```
```
if( $("#mediaItemsListDest li").length >= 1 ) {
//remove it when the ul contains an li
$("#mediaItemsListDest p").css('display','none');
}
```
or
```
if( $("#mediaItemsListDest li").length === 0 ) {
//no li is found, display a message via jquery but don't add it as a
element in the html
$(this).html("Sorry, this is empty");
}
```
or
```
if( !$("#mediaItemsListDest").has("li").length ) {
$(this).html("Sorry, this is empty");
}
```
None of them worked. Do you have a callback in place that can be added to the sortable function to display a message when empty? For instance:
```
$("#mediaItemsListDest, #mediaItemsList, #playlistItemsList").sortable({
emptyMsg: " Not items available",
});
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.