flatpickr icon indicating copy to clipboard operation
flatpickr copied to clipboard

How to append an element <p> in the .selected .endRange <span>?

Open felipevegners opened this issue 9 years ago • 3 comments

I've tried append a <p> element to customize the .selected .endRange <span> style, like the picture below, but I can't find where this <span> was created in the core.

I created a "ghost" element in Chrome Dev Tools to simulate what I want to do.

append_p append_p2

Anyone could help me?

felipevegners avatar Oct 30 '17 12:10 felipevegners

Hello,

How are you trying to append it? Are you using https://chmln.github.io/flatpickr/events/#ondaycreate ?

chmln avatar Nov 07 '17 02:11 chmln

Hi @chmln,

Here's the solution that I found couple days ago:

  function createDay(className, date, dayNumber, i) {
  var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", "flatpickr-day " + className);
  dayElement.innerHTML = '<p class=finalDateClass>' + date.getDate().toString() +'</p>';
  dayElement.dateObj = date;
  dayElement.$i = i;
  dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
      if (compareDates(date, self.now) === 0) {
      self.todayDateElem = dayElement;
      dayElement.classList.add("today");

I don't mind if this was the best approach but it's solved my problem :)

felipevegners avatar Nov 07 '17 10:11 felipevegners

Glad you figured it out. I'd still recommend using onDayCreate, which gives you access to dayElement, but its up to you.

chmln avatar Nov 10 '17 03:11 chmln