programmatically set dropdown multiple selection values with different display text & value?

1,710 views
Skip to first unread message

Cody Innowhere

unread,
Nov 22, 2015, 2:00:51 AM11/22/15
to Semantic UI
Hi,
I'm using "ui multiple fluid search selection dropdown" component, my scenario is that on page load, I want to set default values for dropdown with different display text & actual hidden field value, say, I want to add two user info by default "user1, user2", which are displayed, but I want the hidden value to be the actual login names, say "u...@xx.com,u...@xx.com". Here's my html fragment:

<div class="ui fluid multiple search normal selection owner dropdown">
    <i class="dropdown icon"></i>
    <input type="hidden" id="owner" name="owner" value="$!topology_owner.owner"/>
    <input class="search" autocomplete="off" tabindex="0">
</div>

the problem is, if I set the value of the hidden input to "u...@xx.com", it will actually display "u...@xx.com" instead of desired "user1" on the page. So is there a way to do this? Thanks

Cody Innowhere

unread,
Nov 22, 2015, 2:31:50 AM11/22/15
to Semantic UI
the main problem is, if I set the hidden value on page load, it will automatically add an item to dropdown, thus I have to put the value into a property in the hidden field, say, "data", then I get the desired text to display via an XHR, then append elements like "<a class="ui label" ...>desired text</a>" after the hidden field, but it seems cumbersome although it does solve the problem.

--
You received this message because you are subscribed to a topic in the Google Groups "Semantic UI" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/semantic-ui/om4m4CJE8vc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to semantic-ui...@googlegroups.com.
To post to this group, send email to seman...@googlegroups.com.
Visit this group at http://groups.google.com/group/semantic-ui.
For more options, visit https://groups.google.com/d/optout.

Jack Lukic

unread,
Nov 22, 2015, 12:16:58 PM11/22/15
to Cody Innowhere, Semantic UI
You need to make sure the corresponding `item` includes ` data-value` with the contents you want to appear in `input` with a text node (or alternatively `data-text` that corresponds with the text you want to display)


--
You received this message because you are subscribed to the Google Groups "Semantic UI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semantic-ui...@googlegroups.com.

Cody Innowhere

unread,
Nov 25, 2015, 12:27:32 AM11/25/15
to Semantic UI, e.ne...@gmail.com
Hi Jack,
do you mean I need to add data-text & data-value attributes in the hidden input? doesn't seem to work.
Reply all
Reply to author
Forward
0 new messages