vue-search-select icon indicating copy to clipboard operation
vue-search-select copied to clipboard

Create new option if search returns no results

Open yaliya opened this issue 6 years ago • 5 comments

I have a scenario when an option does not exist in the options list pulled from database and i would like to create it. Basically create if not exists and select if exists. All of the components seem to delete the search text from the input if no match is found.

yaliya avatar May 15 '18 11:05 yaliya

i have same problem

mateus-nunes avatar May 15 '18 14:05 mateus-nunes

I have same problem [2]

ghost avatar May 26 '18 00:05 ghost

I Think, provide "Create new option" feature is not the scope if vue-search-select. But if there is feature like show empty result with text and link that event attached, we can handle this.

_2018-09-11_10_35_48

moreta avatar Sep 11 '18 01:09 moreta

How others are handling this requirement since the functionality is not available in the library yet?

coderabsolute avatar Nov 30 '18 05:11 coderabsolute

@coderabsolute What I do is create an item automatically for each character that is written. For example if you wrote "abc", then a single abc element will appear. id: -1 is a wildcard to know what a new element is. More or less this is my code: <model-list-select @searchchange="getItems"></model-list-select>

getItems(text){
if (response.status == 200 && response.body.results.length! = 0) {
      this.settlementOrigin.items = response.body.results;} 
else {
// If not, we create the same
             this.settlementOrigin.items = [{id: -1, settlement: text}];
}}

felocru avatar Dec 04 '18 06:12 felocru