I have the following HTML:
<div class="folders block">
<div class="ui-widget-content">
<table class="folders-list">
<tbody class="folder">
<tr><td style="text-align: center">Папки: </td></tr>
<tr class="folder-name"><td><i class="fa fa-folder-open"></i><span>Всички</span></td></tr>
</tbody>
</table>
</div>
</div>
And the following jQuery:
$(".folder").selectable({
stop: function() {
$(".ui-selected", this)
.each(function() {
var index = $("table tbody").index(this);
});
}
});
Everything is fine accept when I want to deselect the selected item. Wherever I click nothing happens. I didn't find anything that could help.
If I understand you correctly, there is no straightforward way to do this, but you can use a trick.
When the user click on somewhere outside the container (
.folder) you should do 2 things:.ui-selectedclass of the selected items.Note: It's a generic solution so maybe it will conflict with your other code (
$('html').clickfor example) so be careful.To the code: