You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an app which uses many instances of ember-aupac-typeahead in one page. When I enter the corresponding route, all typeahead components are populated via the selection property. I just noticed that in this moment, all of them trigger the source function to request search results. This doesn't seem to make sense to me, since at this point the user has not interacted with the component and in my case this creates around 50 ajax-requests to the API which take a lot of time to process. Is this on purpose or is it a bug?
The application template shows an ember-aupac-typeahead component which is prefilled via selection. The template shows whether a search request has been triggered so far. It switches to "results have been requested" immediately when the page loads.
Best,
Matthias
The text was updated successfully, but these errors were encountered:
I am guessing that this is happening when the value of the typehead is set.
setValue : function(selection){if(this.get('_typeahead')){// Was failing in tests with this probably due to a stray observerselection=this.get('transformSelection')(selection);if(selection){this.get('_typeahead').typeahead('val',selection);<----------------------HERE}else{this.get('_typeahead').typeahead('val','');}}},
Not sure how to fix this thought because there is nothing in the typeahead documention about this. I found an issue here with a similar (not the same) problem.
I think I figured out a way to work around this problem: in setValue, I store the value of selection and the fact that it has not yet been searched for. Then, in source I can check whether query matches the selection and whether the component has already searched for this value. If not, I can ignore the search request. You can check my proof of concept in this ember twiddle.
It is probably not too elegant, but it solves the problem for now. The better solution would likely be to discuss this with the upstream developers of typeahead.js.
Hi,
I have an app which uses many instances of
ember-aupac-typeahead
in one page. When I enter the corresponding route, all typeahead components are populated via theselection
property. I just noticed that in this moment, all of them trigger thesource
function to request search results. This doesn't seem to make sense to me, since at this point the user has not interacted with the component and in my case this creates around 50 ajax-requests to the API which take a lot of time to process. Is this on purpose or is it a bug?I created an ember twiddle to demonstrate the problem:
https://ember-twiddle.com/328c04b3f57f7ba90f7f502447a58927?openFiles=controllers.application.js%2C
The application template shows an
ember-aupac-typeahead
component which is prefilled viaselection
. The template shows whether a search request has been triggered so far. It switches to "results have been requested" immediately when the page loads.Best,
Matthias
The text was updated successfully, but these errors were encountered: