Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

So, what is the right way to use reactive data with this plugin? #60

Open
mauricemojito opened this issue Dec 16, 2017 · 4 comments
Open

Comments

@mauricemojito
Copy link

mauricemojito commented Dec 16, 2017

I'm trying to use 2 autocompletes in one form. So I need to get the value of each input, but I can't find the right information to do it. I read about the :init-value, but It didn't work. I looked at the directive, but the only reactive data is type.Is there a work around?

@mauricemojito
Copy link
Author

Okay, one work around is using:
onShouldGetData="getFilter"and :onSelect="setFilter"

getFilter(value) {
this.filter = value;
axios.get('/api/location?filter=' + value)
.then(response => {
this.options = response.data.data;
});
},
setFilter(value) {
this.filter = value.name;
}

But is there a more cleaner way to do it?

@animexxx
Copy link

I have the same question and I wanna get the value when not select any result too.

@dmouroutis
Copy link

If I understood that correctly, you basically want to know the input value at any given moment without user having to select an option?

If yes then you could use the following prop on component

<autocomplete
...
:onInput="callbackEvent"

Basically you do not interrupt (if you don't want to) the automatic ajax request but you access your input value every time.

@animexxx
Copy link

animexxx commented Feb 10, 2018

I use :onBlur="selectBlur" and querySelector to get the value then it solved my problem.

selectBlur: function () {
var val = this.$el.querySelector('.autocomplete-input').value;
this.roomProp.cus_name = val;
}

#Note: should use the id selector instead of class if you have many autocomplete in a document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants