I have below asp.net Listbox which has been decorated with sumoselect.
After selecting an item in dropdown if user deselects the item (none of the item is selected) then user will be prompted a javascript confirmation box and if user clicks on Cancel button of that, then dropdown will continue to hold the values. Below is my code.
<td class="ievent" style="width:22%; padding-bottom:10px; padding-right:30px;padding-left:10px;">
<asp:ListBox ID="ListBoxSol" runat="server" SelectionMode="Multiple" CssClass="textbox" Height="22px" Font-Size="Small" Width="230px">
</asp:ListBox>
</td>
if (lastselectedItemIndex == -1) {
var dropselvalue = sessionStorage.getItem("items");
var ans = confirm("If all Internal Solution are de-selected than Solution Revenue value will be saved as 0. Do you want to de-select all?");
if (ans == true) {
$('#LabelSolRev').hide();
$('#TextBoxSolRev').hide();
}
else {
event.preventDefault();
//$("#ListBoxSol option").find('AI Solutions').attr("selected", true);
//$('#ListBoxSol option').(":checked");
$("#ListBoxSol option").each(function () {
if ($(this).html() == "AI Solutions") {
$(this).prop("selected", true);
//$(this).checked(true);
$(this).removeClass("opt");
$(this).addClass("selected opt");
$(this).trigger("click");
return false;
}
});
}
}
But in my case multiselect dropdown is unable to hold the values after deselect by using the code given. Can anyone please suggest how to handle this scenario?