jquery-ui-multiselect-widget icon indicating copy to clipboard operation
jquery-ui-multiselect-widget copied to clipboard

How do I hide empty option values with classes?

Open ghost opened this issue 4 years ago • 3 comments

What is the current behavior?

My empty value tags still appear in the ui.

ghost avatar Aug 11 '21 13:08 ghost

You might consider using the removeOption method on the widget. The options that are rendered are li tags not option tags. The widget just uses the option tags from the original select to build the list before the widget takes the place of and hides the underlying select.

Otherwise you might try using css to hide li tags with no text that are under the ui-multiselect-checkboxes css class.

mlh758 avatar Aug 11 '21 13:08 mlh758

You might consider using the removeOption method on the widget. The options that are rendered are li tags not option tags. The widget just uses the option tags from the original select to build the list before the widget takes the place of and hides the underlying select.

Otherwise you might try using css to hide li tags with no text that are under the ui-multiselect-checkboxes css class.

Otherwise you might try using css to hide li tags with no text that are under the ui-multiselect-checkboxes css class.

This seems my best option I didn't know it rendered in li tags. So the css would then be ui-multiselect-checkboxes li[value=""] {display: none'}

ghost avatar Aug 13 '21 03:08 ghost

If you inspect the HTML on the demo page, it's not the li that has a value but the input tag underneath it. You'd end up with a selector like 'li input[value=""]'. That selects the checkbox though. You would need some JavaScript to hide the parent based on that since I don't think css has a parent selector.

Something like: document.querySelectorAll('li input[value=""]').forEach((el) => el.closest('li').className = "hidden")

mlh758 avatar Aug 13 '21 16:08 mlh758