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.

feat(popover,tooltip): Support something akin to 'selector' in BS4 popover

See original GitHub issue

ref: http://v4-alpha.getbootstrap.com/components/popovers/#options

Use case: allow popover to be delegated to 3rd-party components. It could support selectors or (more importantly) element refs.

For instance, I’m using a component from a module and I want to have a popover point to it, but its not positioned exactly where its parent element is, so putting the popover on the parent doesn’t look right. The only way I can get it to work properly is to add ngbPopover directly to the component’s template.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
keljoundicommented, Apr 3, 2019

Similar real-life example:

I am using Fullcalendar in an application and want to be able to bind popovers to the calendar events to show details at a glance.

I am able to work around the problem and get popovers to work in a dirty way. I defined a single popover element in the HTML and in the TS component I reference the popover via ViewChild and set title and content. To correct the location I set the private _elementRef variable and it seems to work, and just ignore the ts errors with @ts-ignore.

@ViewChild('popover') public popover: NgbPopover;
 ...
 eventMouseEnter(el: HTMLElement, event: EventApi) {
        ...
        this.popover.ngbPopover = event_data['content'];
        this.popover.popoverTitle = event_data['title'];
        // @ts-ignore
        this.popover._elementRef = new ElementRef(el);
        this.popover.open();
   }

This is a quick and dirty workaround and something as simple as exposing the _elementRef or better yet adding a function to change the _elementRef could do the trick. My first thought was to extend the NgbPopover class or add a prototype function but wasn’t successful and have read on other issues that extending features of NG-Bootstrap isn’t really feasible.

0reactions
keljoundicommented, Mar 13, 2020

@cribbstechnologies From my package.json: “@fullcalendar/angular”: “^4.3.1”

I am using pretty standard code for the template:

 <full-calendar #calendar
   ...
 (eventMouseEnter)="eventMouseEnter($event)"
 (eventMouseLeave)="eventMouseLeave($event)"
 (eventClick)="routeToCalendar()"
 (dateClick)="routeToCalendar()"></full-calendar>

 < div [ngbPopover]="popContent" popoverTitle="Popover on top"
      #popover="ngbPopover" triggers="manual" container="body">
 < /div>
 < ng-template #popContent>
 	<div [innerHTML]="popoverContent"></div>
 < /ng-template>

It has been a while since I’ve had to mess with this part of my app so I may be forgetting some details. Let me know if you need anything else

Read more comments on GitHub >

github_iconTop Results From Across the Web

Popovers - Bootstrap
Popovers that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements. Copy. $('#element').
Read more >
Bootstrap 3 popover & tooltip on same element - Stack Overflow
I'm trying to simply add a popover and tooltip to an element, ... The popover works as it should but the tooltip doesn't...
Read more >
Bootstrap popover - YouTube
Tagsbootstrap popover examplesbootstrap popover on hoverbootstrap popover on hover and clickbootstrap popover close on click ...
Read more >
Bootstrap Popovers - examples & tutorial
Responsive popover built with the latest Bootstrap 5. Popover is like a tooltip, but it can persist after hovering off. It allows displaying...
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