Enhance original dropdown for select use.
Dropdown is enhanced from original dropdown component. It is used as select
.
As use of Dropdown. To realize selector, you should add attribute data-type="selector"
on the dropdown-toggle and add an span
class of dropdown-value
inside it.
For options list, ul should add class dropdown-options
. And for option item, you can set value in li > a
attribute value
. If not set value, its value will be same as its html content.
<button class="btn dropdown-toggle" data-toggle="dropdown" data-type="selector"> <span class="dropdown-value"></span> </button> <ul class="dropdown-menu dropdown-options"> <li><a value="yourValue">option</a></li> ... </ul>
Append the option name to data-
, as in data-to
.
Name | type | default | description |
---|---|---|---|
to | string | Set the target input element. When user change the select option, the value of target input element will also be changed. | |
And other options is same to original Dropdown Component. |
<input id="sel_tgt" type="hidden" /> <button class="btn dropdown-toggle" data-toggle="dropdown" data-type="selector" data-to="#sel_tgt"> <span class="dropdown-value"></span> </button> <ul class="dropdown-menu dropdown-options"> ... </ul>
Event | Description |
---|---|
change |
It will trigger when change its value. It'll also trigger change event for data-to element.
|