Skip to content

Clearing and hiding check boxes #171

Description

@ready4data

I modified the code for the check boxes to hide the ones with (0) items after filtering.

      var c = $(this), count = 0
      if(result.length > 0){
        count = jQ.where({ 'litType': c.val() }).count;
      }
	  //hide the checkboxes if value is 0////////
	  if (count ==0) { 
		  $('#'+c.val().replace(/\s/g, '')).hide();
	  }	else {
		  $('#'+c.val().replace(/\s/g, '')).show();
	  }	  
      c.next().text(c.val() + '(' + count + ')')
    });```

I'm trying to figure out how to uncheck All and the items that are left so 
the user can just pick the item they want. Currently they have to first 
uncheck All, then check the item they actually want.

Activity

  1. PeterPan73 commented on Oct 28, 2018

    @PeterPan73

    Hi @ready4data did you find any solution? And I'm interested in that.

  2. ready4data commented on Oct 29, 2018

    @ready4data
    Author

    I did do this which works but produces some unexpected filtering.
    I have two different sections with checkboxes Literature Type and Product Type
    After entering your search terms, the page refreshes and the checkboxes are all unchecked.
    If I check off an item it either area, it works. If I select an item in one area and then the other, it gives unexpected results in the search.

    function afterFiltered(){//Unchecks the boxes after a search
      $('#litType_criteria :checkbox').prop('checked', false);
     /$('#prodType_criteria :checkbox').prop('checked', false);  
    }
    

    And added that function to the callback.

  3. PeterPan73 commented on Oct 29, 2018

    @PeterPan73

    Thanks for the answer. But if all are unchecked by default, when you checked one of the checkbox, the counter of the others is reset(will be 0). Did you find any solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions