question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[hitsWidget]: Provide an `onClick` handler on the hits

See original GitHub issue

We sometimes need to trigger a specific behavior when people are clicking the hits results displayed. Something like opening more details in a lightbox, or in a side panel. And we usually need context about the specific hit that was clicked. There is currently no built-in way to do that.

For example, on the Marvel demo I open the side panel when you click on a result hit. I managed to do that by listening to the click event on the hits wrapper (and filtering only on event targeting the hits themselves) through and external jQuery binding ($('.hits').on('click', '.hit', (event) => {})). I also put the hits details in a JSON encoded form in an hidden textarea to get it.

This is hacky and maybe we could directly embed this into the widget. I suggest something like:

search.addWidget(
  instantsearch.widgets.hits({
    container: '#hits-container',
    onClick: (event, data) => {
      // event is the usual event, while data is the data passed to the template
    }
  })
);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
bobylitocommented, Jun 6, 2016

JSON.stringify in a single data attribute?

0reactions
vvocommented, Jun 10, 2016

Revisiting this, given our renderers proposal, we might finally implement this in the default hits renderer since this is a common pattern in recent demos. And you don’t want to render the hits yourself for such a simple usecase.

Moved to #1078

Read more comments on GitHub >

github_iconTop Results From Across the Web

hits | InstantSearch.js - Algolia
An InstantSearch.js widget for displaying a list of results.
Read more >
How to use react router with Algolia search hits?
I'm using Algolia's react instant search and I want to know what code I can use that'll send me to a specific page...
Read more >
Widget Interaction Component - Unreal Engine Documentation
Transmits a list of characters to a widget by simulating an OnKeyChar event for each key listed in the string. Set Custom Hit...
Read more >
What is the Widget Interaction Component in Unreal Engine 4
What is the Widget Interaction Component in Unreal Engine 4https://docs.unrealengine.com/en-US/Engine/UMG/HowTo/VirtualKeyboardsSource ...
Read more >
Flutter: Hit-test outside parent bounds with `DeferPointer`
The core idea is pretty simple: If we can't do the hit test ourselves, then just punt it to another widget further down...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found