I am using jQuery UI selectable widget. I saw a solution at Is there a way to change event parameters in jQuery? to enable multiple selection (with mouse drag) which works fine. Now I am trying to get the similar feature to unselect multiple elements which doesn't work.
$('#selectlist').on("mousedown", function (e) {
e.metaKey = true; //multiple select true
//e.ctrlKey = true;
}).selectable({
filter: '.select-li',
selecting: function (event, ui) {
debugger;
//if ($(ui.selecting).hasClass('li-planned')) {
// $(ui.selecting).removeClass("ui-selecting");
//}
},
unselecting: function (event, ui) {
//if ($(ui.unselecting).hasClass('li-planned')) {
// $(ui.unselecting).removeClass("ui-unselecting").addClass('ui-selected');
//}
},
stop: function (event) {
//debugger;
//do some work here
}
})
I tried multiple options to achieve but so far I am not able to get it. Any help will be appreciated.
You can simply make your list selectable by
You can multiple select on selectables without using your mouse down.
On unselecting multiple (based on selecting above),
1.a. Select one, and all the others will unselect
1.b. Select an empty area in you list (ei. space between list1 and list2), and all will unselect
2. Pressing Ctrl while unselecting.
See jQuery-ui's demo http://jqueryui.com/selectable/#default