I'm using jQuery Selectable (http://api.jqueryui.com/selectable/) and need to know the number of elements selected once the operation is complete.
//Example Code
$('body').selectable({
selected: function(event,ui) {
var $selectedItems = ui.selected;
alert($selectedItems.length); // This is always 1
}
});
The variable "selectedItems" returns the elements that are selected. I can loop through them like this:
$selectedItems.each( function() {
// do something
});
But I simply want to know how many elements are selected.
The "length" property always returns 1. And it doesn't seem right to put a counter in the above loop. There must be some way of doing this?
Thanks for any help.