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
Change input value by props #84
Comments
@Diokuz You need to use a controlled behaviour (use the |
Hi @moroshko, im trying to use autosuggest with the Aurelia framework. The thing is, if i understood correctly, that i need to be able to change the state through this.setState({value}) from your example ( i have little to no knowledge of React yet). My problem is that inside my getSuggestions function i need the this context to show to my Aurelia class, so that i have available its data. The functions i pass to Autosuggest since they are invoked elsewhere have the this context changed so i need to .bind() the functions to my class. The problem after this is that i dont have access to the this.setState({value}) function. here is a gist of my class so that you can have a better view of it. How else can i get the instance of Autosuggest ? |
@spideynr You should be able to access |
@moroshko i also saw that getSuggestions has the instanceof Autosuggest but i need to be able to use the this.suggestions variable of the class (thats two-way binded with aurelia) inside the function. Therefore i binded it on the class context and losing the Autosuggest context and this.setValue . Any ideas as to how to implement it? Extending my class with react.component would give me access to setState? |
@moroshko i updated my gist with some temp fixes. I placed my class context and the Autosuggest context on let variables so that i can have both in the same block scope. Now i have another peculiar problem. You will see on EDIT: I managed to solve my problem temporarily but using deferring calls. |
@moroshko According to controlled behavior, I should use input's Also, maybe there's a way to clear autosuggest's value using uncontrolled behavior? |
@spideynr Sorry, I'm afraid that I'm not familiar with Aurelia enough to help you. It feels weird to see a statement like |
@web2style When the behaviour is uncontrolled, only user interaction can change the input value. It cannot be controlled programatically. In a controlled component though, you can provide |
@moroshko Yeah you were right about Its still somewhat strange though as to why |
@spideynr You shouldn't need |
@spideynr You can use this example as a starting point. |
@spideynr When suggestion is clicked, Can I ask what is your use case for clearing the value when suggestion is selected? |
@moroshko i have a list of users on a form and when i select a user i automatically pass them to an array and want the input cleared so that more users can be searched/selected after. Kinda like a multi-select form. |
@spideynr I see. I think using setTimeout then makes sense, knowing that when suggestion is clicked, Autosuggest sets the input value (so if you want to override it - do it in the next tick). |
@spideynr Just wanted to let you know that in 3.0 you don't need
|
Hi there.
I have a problem: I use suggestor as element of user-edit form. After first user is edited, I open second user. Now I have old value from first user in suggester input.
I need to change input value by props, not by any user interactions.
How can I do that?
The text was updated successfully, but these errors were encountered: