Reputation: 2280
this is preselectiong my .item.active.selected
but unfortunately it also fires the onChange
. Is there another way?
$(function() {
$.each($(".ui.dropdown"), function(i, dropdown) {
selected_value = $(dropdown).find(".item.selected").data("value");
$(dropdown).dropdown("set selected", selected_value);
});
});
Upvotes: 2
Views: 1409
Reputation: 645
Yes, you can set value and text instead.
So,
$(function() {
$.each($(".ui.dropdown"), function(i, dropdown) {
var val = $(dropdown).find(".item.active").data("value");
var text = $(dropdown).find(".item.active").html();
$(dropdown)
.dropdown("set value", val)
.dropdown("set text", text);
});
});
But why do that?
You can pre-select a value by:
<input type="hidden" value="my_val" />
field in div-based dropdownsselected
attribute to the option
for select-based dropdownsUpvotes: 5