how i can implements this feature by set a setting ?
<div class="ui search selection dropdown">
<i class="dropdown icon"></i>
<input name="language" type="hidden" class="" value="fa_IR">
<input class="search" autocomplete="off" tabindex="0">
<div class="default text"></div>
<div class="menu " tabindex="-1">
<div class="item" data-value="fa_IR">賮丕乇爻蹖 (丕蹖乇丕賳)</div>
</div>
</div>
$('.ui.dropdown').dropdown({
forceSelection : false,
fullTextSearch : true,
onHide : function(){ //feature is here
$(this).dropdown('set selected',$(this).dropdown('get value')).find('>input.search').val('');
},
});
There is no setting, but an existing behavior to shorten your code:
$(this).dropdown('remove searchTerm');
yes. but i think this feature must be added to setting for prevent complexity.
What is your use case so forceSelection:true does not work for you? It will remove the searchTerm when it does not match any dropdown entry as expected
See http://jsfiddle.net/5uckpnga/
The intention of forceSelection:false basically is to _not_ remove the searchterm but let the user select something which is not in the list
because when i set forceSelection to true and be typed part of text and focus out of input , one of item in list , selected!
is not good.
I am still not understanding your use case.'forceSelection:true of course selects anything matching while typing, that's the intention of it.
The code you are providing always removes the search term when hiding the menu. That is not the intention of forceSelection:false. It's meant to be able to select something which is not in the list.
I am not sure if we really should add an option to always remove the searchterm on hide if nothing is found... Let's see what others say
@ziaratban After thinking about it for a while now, i think we can make use of the already existing allowAdditions setting. This is false by default and should remove the searchterm when it does not match anything.
I prepared a PR to support that here https://github.com/fomantic/Fomantic-UI/pull/1002