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

react-search-refiners: Attach event listener to all results items #337

Open
2 of 3 tasks
theibrahimi opened this issue Oct 29, 2019 · 1 comment
Open
2 of 3 tasks

Comments

@theibrahimi
Copy link

Hello,
since we can not add onclick event to the display, I'm trying to attach event listener to all resuls retreived by the search query.
I'm adding this portion of code to the "_getSearchResults" method of the file "SearchResultsCntainer" :
const btn: NodeListOf<Element> = document.querySelectorAll('.template_listItem'); btn.forEach((b: HTMLDivElement) => { b.addEventListener('click', (event: any) => { this.handleClickgetuserproperties(${b.id},${b.lang},${b.title}` ); }, false);

    });`

It work only for the first page, when i click next page of pagination, the event is not attached on the 2nd page results.

How can I attach it to all results?

Regards,

Category

  • Question
  • Bug
  • Enhancement
@wobba
Copy link
Contributor

wobba commented Oct 29, 2019

You would need to do this for each time render is fired, or create a DOM change listener, which you use to attach the events.

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

2 participants