Open ilvalerione opened 7 years ago
I had that issue, I set the limit
to zero initially and then when someone types I change limit
to 4. Sorta acts as a disable initially and reenable when someone types.
<div class="col-xs-5" v-on:keyup="enableTypeahead">
<label for = "name">Style</label>
<typeahead
v-model="beer.style.stylename"
placeholder="Style"
async-key="data"
:async="getAsyncStyleUrl"
:template="asyncStyleTemplate"
:on-hit="callBackStyle"
:limit="typeaheadLimit">
</typeahead>
</div>
data (){
return {
asyncStyleTemplate: '{{ item.stylename }}',
typeaheadLimit: 0
}
}
enableTypeahead() {
this.typeaheadLimit = 4;
}
Nice workaround @tehjrow
I made it work by alterring the source (in Typeahead.vue, or the js created from it): I added a prop to the component ( around line 35 ):
matchStart: { type: Boolean, default: false },
supressInitialSearch: { type: Boolean, default: false }, // added
onHit: {
And then I changedf the created
hook to respect this property (around line 125)
if (! this.supressInitialSearch) {
this.__update();
}
And now the property can be added to the typeaheads when needed:
<typeahead
supress-initial-search
:on-hit="...">
This seems to work for me, to prevent the initial search and popup
Hello, I'm binding Typeahead with v-model to my internal variable.
<typeahead async="/api/countries?q=" v-model="val.country" :template="countriesSuggestionsTemplate" :limit="5" :on-hit="selectCountry" placeholder="Search...">
But when I declare a default value for val.country Typeahead open automatically the drop down list. I think because the plugin finds a "changed" event of the input value.
Is there a way to close programmatically the dropdown list or to block this behavior?