I have table rows that are sortable depending on whether certain radio buttons are checked or not. The sortables are initialized on document.ready
as follows:
I've been trying to do the same thing. I really wanted the items feature rather than disabled. As pointed out above, there is a weakness in the jQueryUI implementation whereby the sortable don't refresh the items list should the items matched by the selectors change.
To get around this, I simply destroyed and reinstantiated the sortabled. I've adapted Hannele's JSfiddle to demonstrate (http://jsfiddle.net/Sxg8D/140/).
$("#sorted-list").sortable({
items:"li:not(.disabled)"
});
$("#sorted-list input").click(function() {
if (this.checked) {
$(this.parentElement).removeClass("disabled");
} else {
$(this.parentElement).addClass("disabled");
}
$("#sorted-list")
.sortable( "destroy" )
.sortable({
items:"li:not(.disabled)"
});
});