Basically, I just want to know how to check if a sortable list is empty or not. I have an ajax call after a list is updated, but if there are no items I want to bypass the call because it will be unnecessary.
What would be the method to achieve this? Is there a simple method?
Using jQuery you can attempt to select the sortables and test how many elements are returned:
The above code assumes that each of the elements in your sortable have the class
sortable-class. All you really need is a unique selector that will only find your sortables. For instance if your sortables are all children of an element then your selector could look like this:HTML
JS
Here’s some documentation if you’re into that kind of thing: http://api.jquery.com/length