Semantic-ui: Unclear how to retrieve value from dropdown

Created on 5 Dec 2013  路  5Comments  路  Source: Semantic-Org/Semantic-UI

It's unclear how to retrieve the current value from the dropdown.
Calling $('.ui.dropdown' ).dropdown('get value') returns a jquery object.

The example:
$('.your.element')
.dropdown('behavior name', argumentOne, argumentTwo);

Does not work

Enhancement

Most helpful comment

get value only returns a value if used with a hidden input field, see selection example. I can see why this would be confusing for examples that do not use form data.

If you want to store/get value use html like that in the form example for now.

<div class="ui dropdown">
  <!-- needs this next line for value storage !-->
  <input name="gender" type="hidden">
  <div class="text">Female</div>
  <i class="dropdown icon"></i>
  <div class="menu">
    <div class="item" data-value="1">Male</div>
    <div class="item active" data-value="0">Female</div>
  </div>
</div>

I'll see into saving values to DOM metadata in cases where no input is used. I'll mark this aspect as an enhancement.

All 5 comments

get value only returns a value if used with a hidden input field, see selection example. I can see why this would be confusing for examples that do not use form data.

If you want to store/get value use html like that in the form example for now.

<div class="ui dropdown">
  <!-- needs this next line for value storage !-->
  <input name="gender" type="hidden">
  <div class="text">Female</div>
  <i class="dropdown icon"></i>
  <div class="menu">
    <div class="item" data-value="1">Male</div>
    <div class="item active" data-value="0">Female</div>
  </div>
</div>

I'll see into saving values to DOM metadata in cases where no input is used. I'll mark this aspect as an enhancement.

Strange in my example, I have that input field - but the returned result is still a jquery object

Create a jsfiddle, i've tested in docs but i need an accurate test case

Dropdown changes deployed in 0.10.0, value can now be retrieved without <input> field

Ill mark this as closed, if you have any more problems feel free to update the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhaoyao91 picture zhaoyao91  路  3Comments

rdzidziguri picture rdzidziguri  路  3Comments

mllamazares picture mllamazares  路  3Comments

vinhtq picture vinhtq  路  3Comments

larsbo picture larsbo  路  3Comments