-
Notifications
You must be signed in to change notification settings - Fork 287
DE SELECT all selected option added
Raheel Hsn edited this page Apr 27, 2017
·
5 revisions
By:
Hi,
I needed a DE-SELECT option so ive created one. Im posting it here so if any body needs it.
Scenario: List has many many options, is preselected with a few of them. So who has the time to scroll down like 100s of them to uncheck the ones checked previously! Furthermore, The SelectAll option on the other hand takes 2 clicks to deselect instead of 1, and its too slow (I guess someone mentioned that it fires event for each checkbox).
So here is the code, ive placed select tag inside a span with id par_sumo. Also the sumo is initialised using selectAll: true
:
$('#par_sumo .SumoSelect .SelectBox').click(function(){
if($(this).parent().hasClass('open')){
$.desel_sumo_multi('#par_sumo', ($(this).attr('title')==''));
}
});
/** DESELECT SUMO **/
$.desel_sumo_multi = function(id, is_empty)
{
if(is_empty)
{
$(id+' .select-all').hide();
return false;
}
else
{
$(id+' .select-all').show();
}
$(id+' .select-all').addClass('selected').removeClass('partial');
$(id+' .select-all label').html('De-Select All');
$(id+' .select-all.selected > label').css('color', '#EA5745');
$(id+' .select-all.selected > span i').css('background-color', '#EA5745');
$(id+' .select-all').click(function(){
$(this).parent().siblings('.SelectBox').find('span').html();
$(this).hide();
//$(id+' .btnOk').click(); //auto click
});
};