I've encountered a problem when trying to implement 2 dropdowns in semantic-ui.
What I want to happen is that when I change the selected item in the first dropdown the second dropdown will be automatically be cleared from its pervious selection (this is the first step in implementing an automatic change to the content of the second dropdown).
I've created a simpler version containing 2 dropdowns and a clear button in JS bin : here.
The code:
var $one = $('#one'),
$two = $('#two');
$two.dropdown();
$one.dropdown({
onChange :function(val) {
$two.dropdown('clear');
}
});
$('.button').on('click', function() {
$('#two').dropdown('clear');
});
Here I've encountered multiple problems:
The first problem I encountered was that the clear button won't clear both dropdowns unless both dropdowns are only initialised and no other settings added in the initialisation (i.e $(".ui.dropdown").dropdown()).
The second problem is that in the provided code the a dropdown will be cleared (only the second dropdown will be cleared for some reason, and not the first) only if the selector for the clear button will be $(".ui.dropdown) , if I use $("#one")/$("#two") the button won't clear the dropdown.
And the third problem , is that when a change occurs in the first dropdown the second dropdown is not being cleared , which is my ultimate goal.
Any thoughts or suggestions will be greatly appreciated.
Users can show the dropdown in disabled state and do not grant him to change the state. Semantic UI Dropdown Disabled State Class: disabled: This class is used to set the dropdown status to disabled.
The dropdown list we have used here may appear similar to the dropdowns we have used in our jQuery menu component. The key difference with the dropdown list component is that the currently selected item is always exposed and the purpose is to indicate that the user can toggle between options.
A dropdown menu is a design pattern letting you display a list of contents, navigation points, and functions without flooding the user with many options simultaneously.
Use any element to open the dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.
$(document).ready(function () {
$("#super_type").dropdown({
onChange: function (val) {
$('#subtype_list').dropdown('clear');
});
});
This is the best and easy solution provided by semantic UI.
$('.ui.dropdown').dropdown({
"clearable": true
});
By default the value of clearable
setting is false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With