0

I have a popup I've created in d3.js, where it's basically a Div that I scale to 1 on a click-event, and scale to 0 on a second click event anywhere else (i.e. click-off event).

Without being able to post all the code in a reproducible example, here's the relevant code.

The issue:

The popup works fine, until a link is added within the popup html (this line: "hello".link("https://www.google.com")). When a click-able link is added, you can't scroll the popup and it appears that all pointer events are disabled. I'm not sure what about adding a link would cause it to do this.

I've tried to use href instead of .link and it still does not work.

javaScript:

    var LeafletDiv = d3.select("#content").append("div")   
        .attr("class", "county2014Tooltip")  
        .style("opacity", 1)
        .style("scrollTop", 0)



 var events = mapG.selectAll("circle")
        .data(eventArray)
        .enter().append("circle")
        .attr("class", 'events')
        .style("display", dateMatch)
        .style("pointer-events", "auto")
        .attr("classed", "visible")
      
        .on("click", function(d) { 
            console.log('first click!')
            $('body').css({
            overflow: 'hidden'
            });

        LeafletDiv.transition()        
            .duration(200)      
            .style("opacity", .9)
            .style("transform","scale(1)")
         
                var popInfo = '<br/>' + d.EventDate
                +  '<br/>' + "hello".link("https://www.google.com") //this causes it to break
                + '<br/>'
                             
                appendText.push(popInfo+ '<br/>' + '<br/>')
                                        
                })

            LeafletDiv
                .html( appendText.join(""))
                .style("pointer-events", 'all')

CSS:

div.county2014Tooltip { 
    word-wrap: normal;
    position: absolute;
    pointer-events:none;
    overflow-y:scroll; 
    overflow-wrap: break-word;
    word-wrap: break-word;
    display:inline-block ;
}

Thank you.

DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81

3 Answers3

1

Try updating your problem line to this:

var popInfo = '<br/>' + d.EventDate
+ '<br/><a href="https://google.com">hello</a>' //changed to a html link tag
+ '<br/>'
Adam Neuwirth
  • 529
  • 5
  • 10
0

I usually don't use the link method as it is deprecated, and prefer the href property. Not sure if this would solve your problem, but is best practice anyway. Good Luck!

videap
  • 66
  • 5
0

I figured out the answer to this, or at least something that got it to work. I only put the link in the popup initiated by click, and that worked. When I put the link in both popups (the one initiated by hover and click), it broke.

halfer
  • 19,824
  • 17
  • 99
  • 186
DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81