I am trying to make a select list indented by parent / child / grandchild. See below:
http://jsfiddle.net/Lmsop4k7/
$('#theParentList').selectable({ filter: 'li div', selected: function (event, ui) { var selectedText = $(ui.selected).text(); $("#selectedNode").text(selectedText); if ($(ui.selected).hasClass('selectedfilter')) { $(ui.selected).removeClass('selectedfilter'); } } });
But I have many problems related to the "unselect" functionality (that is, without pressing the Ctrl key). I also don’t want to “snap” Ctrl automatically to the mouse down (as described in some other solutions), b / c I only need one element selected at a time. In addition, I just want to understand how to make a control flow to deselect events (for example, "selected:").
What am I doing wrong here? As you can see, the selection is selected correctly, since the text field is updated correctly with the correct text. However, when I click on an already pressed item to “deselect” (without holding Ctrl), it does not deselect. I believe that even in this situation, the "selected" event fires - but, obviously, something is wrong with my "selected:" code. Very upsetting ..
Thanks to everyone.
source share