guylabs / ion-autocomplete

A configurable Ionic directive for an autocomplete dropdown
MIT License
264 stars 88 forks source link

Multiple instances of "ion-autocomplete-container" on view change #210

Open goclixy-core opened 8 years ago

goclixy-core commented 8 years ago

Ion Template Modal is not closing on view change. I also noticed, two instances of the "ion-autocomplete-container" on the view change. I have only one "ion-autocomplete-container" on my view page, why not the first one is deleted on view change. `

goclixy-core commented 8 years ago

EDIT Ionic dupicates some HTML elements in order to achieve smoother transitions. For instance, in an ionNavBar it duplicates its content in 2 blocks such as these, and one only is visible except during transitions: `

` An element with an HTML ID/CSS Class will be duplicated. I believe having 2 elements with the same ID/Class in the DOM is forbidden in the HTML spec. Using document.getElementById/document.getElementByClass will only return one of these elements. This is the reason why ionAutocompleteElement is not working. I tried to disable cache, but it did not work. Do you have a solution for this?
guylabs commented 8 years ago

Hi @parveensaini5

I see your point but for what do you need to access the search element?

Thanks and regards,

Guy

goclixy-core commented 8 years ago

Hi,

I need multiple instances of ion-autocomplete on a single page, I want to call them on button click. They are working well on page refresh, but on view change, click is not working because of multiple instances of the same code.

Regards

Parveen

guylabs commented 8 years ago

Hi @parveensaini5,

could you maybe create a codepen example which is reproducing this? And please follow this guide here to create an issue: https://github.com/guylabs/ion-autocomplete#guidelines-to-report-an-issue

Thanks and regards,

Guy

goclixy-core commented 8 years ago

Hi

I don't think this error can be reproduced with codepen, we need to switch between multiple views to produce this error. Everything is working perfect on a single view or page load. Issue occur only on view change. I used a temporary fix to solve this issue:

if(ionAutoCompleteElement.length > 0) { angular.element(ionAutoCompleteElement[0]).removeClass("search")}

Thanks and regards

Parveen