Adding custom data attributes to air-datepicker-cell
alexbogias opened this issue · 7 comments
Can you please add the option to add more data attributes to air-datepicker-cell element like data-year data-month etc. I need to add bootstrap 5 tooltip
Hello @alexbogias! You could use onRenderCell
option to add custom html elements.
new AirDatepicker('#el', {
onRenderCell({ date, cellType }) {
if (cellType === "day") {
return {
html: `<div data-custom-attribute='tooltip' class="air-datepicker--cell-inner">${date.getDate()}</div>`
};
}
}
})
In this case add some custom styling to stretch inner content of the cells:
.air-datepicker--cell-inner {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
oops) Seems like a bug.
Great job @t1m0n. Waiting for the release...
@alexbogias new version is released! Thank you for the suggestion and bug report!
Refactored in my project and works great @t1m0n !
My thing is now that I have to trigger tooltip initialization after onRenderCell event.
I found out that I have to trigger this bootstrap tooltip init function to run after onChangeViewDate and onShow with 500ms timeouts because the onRenderCell rendering needs some time I suppose...
Is there any hook that I don't know after onRenderCell, so I can trigger it and tooltip and show up faster?
(PS, Sorry for my English!)