Topic: Popover content funtion, this not bound as specified
nilsw free asked 1 year ago
Expected behavior
The documentation specifies the content option for the Popover API:
content string | element | function Default content value if data-mdb-content attribute isn't present.If a function is given, it will be called with its this reference set to the element that the popover is attached to.
Actual behavior
The function does not have this set to the popover trigger element. Is this related to https://github.com/twbs/bootstrap/issues/38720 ? However, unlike in the description there, the element is not a direct argument either.
Resources (screenshots, code snippets etc.)
initSummary: () => {
const triggers = document.querySelectorAll("[data-function='trigger-summary']");
triggers.forEach((trigger) => {
const uuid = trigger.dataset.uuid;
const popover = new mdb.Popover(trigger, {
html: true,
title: trigger.dataset.title,
content: kulturnav.summary, //(uuid),
customClass: trigger.dataset.customclass
});
});
},
The function kulturnav.summary() is called, but this is set to Window in Firefox and undefined in Chrome. I need to get the uuid data element in the content function.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: MDB5 6.4.2
- Device: Laptop
- Browser: Firefox, Chrome
- OS: Ubuntu 22.04
- Provided sample code: No
- Provided link: Yes