Is it possible to react to clicked "a href" links?

I currently have a computed list that is rendered via insertUI like this
(note that in this case for simplicity the list is hardcoded, but it will be dynamically built from data)

      entrylist <- list(
          class="list-group",
          a(href="#", class="list-group-item", 
            h4(class="list-group-item-heading", "entry1"),
            p(class="list-group-item-text", "Description of entry1")
          ),
          a(href="#", class="list-group-item", 
            h4(class="list-group-item-heading", "entry2"),
            p(class="list-group-item-text", "Description of entry2")
          ))
       
      insertUI(
        selector="#entries",
        where="afterBegin",
        ui=do.call(div, entrylist)
        )

What I want to achieve is that, when the user clicks on one of the list entries, a reactive variable is assigned to some sort of unique id, so that I can display the information associated to that entry.

I am not sure actionLink is a solution here, as I am basically having multiple links created ad-hoc and dynamically. Searching google for "shiny reactive anchor" or similar yielded no actual results.

Note that I currently am using the following approach: dropping down to javascript with

  observe({
    print("Received message!")
    print(as.character(input$entry))
  }) 


a(href="#", onclick="Shiny.setInputValue('entry', 'whatever'); return true", class="list-group-item", 

But is there a less low-level way?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.