nathanreyes / v-calendar

An elegant calendar and datepicker plugin for Vue.
https://vcalendar.io
MIT License
4.38k stars 858 forks source link

Jump to date dynamically #435

Open CristianaPereira opened 5 years ago

CristianaPereira commented 5 years ago

I want do mark today's date on start, and some other events like holidays. I will have a table with some other dates, (not events, yet) and I need it to jump to that dates dynamically. Is there a way to do that?

phaberest commented 4 years ago

The initial date is taken from the value you give to v-model, you should be fine by just setting it to whatever you need it to be in your data


...
data () {
  return {
    date: new Date('2019-01-03'),
    ...
  }
},
...
nathanreyes commented 4 years ago

Hey @CristianaPereira your question motivated me to add an easily way to do just that. As of beta-23, you can use the move or focusDate methods. move just moves to the month for the date, where focusDate actually focuses on that date as well. More documentation here.

Here is an example of what I think you are trying to achieve. Select 435 from the list to check it out. Source code for the example is here

renatodeleao commented 4 years ago

[question]

@nathanreyes I don't know if it just me, but I was expecting that if any external control updated v-model with new selected dates, the calendar would react to it and move to the new dates itself automatically.

I've seen the documentation example on how to achieve it, but i'm curious, any particular reason why you went the manual route?

(Great work on this btw, keep shipping ☮️ )

SomeoneIsWorking commented 2 years ago

Having to call focusDate manually is a big bummer. Good thing I use this with a wrapper so I just implemented in the wrapper.