Semantic-UI icon indicating copy to clipboard operation
Semantic-UI copied to clipboard

[Dropdown] Add "Include HTML" option, or modify action to include 'set html'

Open DragosMocrii opened this issue 12 years ago • 3 comments

I am using the dropdown to select an image among several options. Images show nice in the dropdown (when the menu is expanded), however when I select one option, the image is not set as the current value. I believe you are using the .text() method to set it, would it be possible to allow using images as menu options?

Thank you

DragosMocrii avatar Aug 04 '14 12:08 DragosMocrii

I'll look into adding as a dropdown action, set html.

For now, you can use data-text="foo" to pass in an exact value.

For example

<div class="ui dropdown">
  <!-- additional html not shown !-->
  <div class="item" data-text="<img src='dog.jpg'> Dog">
    <img src="dog.jpg"> Dog
  </div>
</div>

jlukic avatar Aug 08 '14 15:08 jlukic

@dragosmocrii

Added a new setting in `1.0preserveHTML which can be used to preserve HTML values instead of just text.

Keyboard navigation added with paging in 1.0

See docs for examples, particularly language select: http://beta.semantic-ui.com/modules/dropdown.html

jlukic avatar Sep 09 '14 21:09 jlukic

Hello, there is a way to use preserveHTML with a dropdown generated by a select tag?

I see https://github.com/Semantic-Org/Semantic-UI/blob/master/src/definitions/modules/dropdown.js#L1562

              return ($choice.data(metadata.text) !== undefined)
                ? $choice.data(metadata.text)
                : (preserveHTML)
                  ? $.trim($choice.html())
                  : $.trim($choice.text())
              ;

but, .html() of an <option> only returns the text without the html tags.

ejosvp avatar Apr 04 '16 15:04 ejosvp