Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  82] [ 7]  / answers: 1 / hits: 20290  / 10 Years ago, tue, march 4, 2014, 12:00:00

Got a problem with semantic-ui dropdown.


I've been using Semantic-Ui, and wanted to change the dropdown item dynamically.
That is, when i choose the value from the first dropdown, the second dropdown's item will change.
But the thing is, when the items are changed, the second dropdown cannot be chose,
the value won't change. The dropdown won't collapse back.



The HTML


The First Dropdown



<div id=programmetype class=ui fluid selection dropdown>
<input type=hidden name=programmetype>
<div class=text>Choose..</div>
<i class=dropdown icon></i>
<div class=menu>
<div class=item data-value=val1>Car</div>
<div class=item data-value=val2>Tank</div>
<div class=item data-value=val3>Plane</div>
</div>
</div>


Second Dropdown



<div id=servicetype class=ui fluid selection dropdown>
<input type=hidden name=servicetype>
<div class=text>Choose..</div>
<i class=dropdown icon></i>
<div class=menu>
<div class=item data-value=select>Choose..</div>
</div>
</div>


..........................


The jQuery



$(#programmetype).dropdown({
onChange: function (val) {
if (val == val1)
{
$('#servicetype .menu').html(
'<div class=item data-value=val1>Saloon</div>' +
'<div class=item data-value=val2>Truck</div>'
);
};

if (val == val2)
{
$('#servicetype .menu').html(
'<div class=item data-value=val1>Abraham</div>' +
'<div class=item data-value=val2>Leopard</div>' +
);
};

if (val == val3)
{
$('#servicetype .menu').html(
'<div class=item data-value=val1>Jet</div>' +
'<div class=item data-value=val2>Bomber</div>' +
);
};
}
});

More From » jquery

 Answers
72

Found it,



I put $('#servicetype').dropdown();
after assigning the values:



$(#programmetype).dropdown({
onChange: function (val) {
if (val == fertility)
{
$('#servicetype').dropdown({'set value':'something'});
$('#servicetype .menu').html(
'<div class=item data-value=acp>ACP</div>' +
'<div class=item data-value=art>ART</div>'
);
$('#servicetype').dropdown();
};
});

[#72177] Sunday, March 2, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryderalfonsos

Total Points: 655
Total Questions: 88
Total Answers: 91

Location: Nauru
Member since Thu, Feb 2, 2023
1 Year ago
ryderalfonsos questions
Mon, Sep 9, 19, 00:00, 5 Years ago
Wed, Feb 13, 19, 00:00, 5 Years ago
Tue, Feb 12, 19, 00:00, 5 Years ago
Fri, Dec 28, 18, 00:00, 6 Years ago
;