Topic: Change highlighted date in datepicker after initialization

develo-per pro asked 5 years ago


I use one input with DatePicker in modal dialog to change the date from different events in FullCallendar. I can preselect and highlight a date in DatePicker using the date-value attribute like: data-value="[2019,0,1]". But is there any method to set the highlighted date in DatePicker dynamically??? A simplified example is here: https://mdbootstrap.com/snippets/jquery/develo-per/1104766?view=side

After Clicking the first button, the DatePicker should open with highlighting the first date and after Clicking the second button, the DatePicker should open with highlighting the second date...


Marta Wierzbicka staff answered 5 years ago


Hi,

have you seen this topic in our documentation: https://mdbootstrap.com/docs/jquery/forms/date-picker/#pre-fill-values?

Best, Marta


develo-per pro commented 5 years ago

Yes, I did. But my problem is, how to preselect DatePicker with javascript dynamically after the page has been loaded. Using something like this: $("#edit-date").data("value", "[2019,7,30]"); dosn't work.


Marta Wierzbicka staff commented 5 years ago

Hi,

OK, so try this code: https://mdbootstrap.com/snippets/jquery/marta-szymanska/1123451.

Best, Marta


develo-per pro commented 5 years ago

OK, thx. But this is not the problem. I repeat my wish again:

I click the first button, then the input and DatePicker should open with highlighting the 2019-01-01 I click the second button, then the input and DatePicker should open with highlighting the 2019-12-31 ... and so on ...

Until now the DatePicker opens only with initialized date.


Marta Wierzbicka staff commented 5 years ago

I mean, in my above solution, when you click the first button you have inside the input date 01-01-2019 and when you click the second button inside the input you have 31-12-2019. And if I understand you well, you want to these dates be visible in our material calendar after clicking input, yes?


develo-per pro commented 5 years ago

Yes, that is what I need.


Marta Wierzbicka staff commented 5 years ago

Hi,

please, check out now: https://mdbootstrap.com/snippets/jquery/marta-szymanska/1123451#js-tab-view.

Best, Marta


develo-per pro commented 5 years ago

Yeah!!! THX. Marta is the best ;)


Marta Wierzbicka staff commented 5 years ago

Hi,

you're welcome.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.8.8
  • Device: All
  • Browser: All
  • OS: All
  • Provided sample code: No
  • Provided link: Yes