Vue Functional Calendar - Easily manipulate selectedDates with the power of v-model

I am trying to set specific dates as selected in the vue functional-calendar (version 2.8.87) component (https://github.com/Digital-Threads/vue-functional-calendar). I have set up the v-model and can successfully detect dates selected by a mouse-click.

However, when I try to set selected dates using a JavaScript function, the calendar does not update to mark or select these dates. The code snippet below illustrates this issue. If anyone has found a solution to this problem, I would greatly appreciate any advice.

<template>
  <div>
    <FunctionalCalendar 
        v-model="calendarData"
        :configs="calendarConfigs"
        ref="Calendar">
    </FunctionalCalendar>

    <b-form @submit="getCal">
        <b-button class="button float-right" type="submit" variant="success">Submit</b-button>
     </b-form>
  </div>
</template>

<script>
import { FunctionalCalendar } from 'vue-functional-calendar';
export default {
  components:{FunctionalCalendar},
  name: 'CustomerArea',
  data() {
    return {
      calendarData:{
        selectedDates : []
      },
      calendarConfigs:{
        isMultipleDatePicker : true
      },
    };
  },
  methods: {
    getCal: function(){
      console.log("getCal called");
      this.calendarData.selectedDates = [{date: '21/7/2020'}];
    }
  }
};
</script>

Answer №1

It is essential to ensure that all other values are set (at the very least to false/invalid) in order for the selectedDates to be displayed accurately:

this.calendarData.selectedDates.push({ "date": "21/7/2020", "dateTime": false, "hour": "00", "minute": "00" });
                this.calendarData.selectedDate = false; 
                this.calendarData.selectedDateTime = false;
                this.calendarData.selectedHour = "00";
                this.calendarData.selectedMinute = "00";
                this.calendarData.selectedDatesItem = "";
                this.calendarData.dateRange = { "start": 
                                        { "date": false, "dateTime": false, "hour": "00", "minute": "00" }, 
                                        "end": { "date": false, "dateTime": false, "hour": "00", "minute": "00" } 
                                        };

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

React State is visible, but I can only access the first array

Currently, I am facing an issue while trying to loop through an array that is nested within another array in my React State. Despite seeing both arrays populated in Dev Tools and successfully looping through the parent array using Object.keys(this.state.pr ...

Angular JavaScript can be utilized for JSON date formatting

I am having trouble displaying JSON data in an HTML table. When I run my file, the date appears as '2018-11-21T00:00:00.000+0000' in the table. However, I only want to display '2018-11-21'. Can someone help me figure out how to split it ...

Issue: Connection Problem in React, Express, Axios

I've encountered an issue while attempting to host a website on an AWS EC2 instance using React, Express, and Axios. The specific problem I'm facing is the inability to make axios calls to the Express back-end that is running on the same instanc ...

Is there a way to update a variable in a controller using AJAX?

Is it possible to update a variable in the controller using Ajax? Controller: $basl = array(2018,11,18,0,0); $deger = 3; $baslamatarihi=Carbon::create($basl[0],$basl[1],$basl[2],$basl[3],$basl[4]); $bitistarihi = Carbon::create($basl[0],$basl[1],$basl[2] ...

Internet Explorer 8 is not compatible with jQuery fadeIn and fadeOut functions

Recently, I created a script that allows for fading in and out an error container. Surprisingly, it seems to work perfectly in Firefox and Chrome but unfortunately fails to function altogether in Internet Explorer 8. If you're interested, feel free t ...

The issue I'm facing is that the ng-click functionality in Angular JS is not functioning properly when the

Upon loading the page, my JavaScript function creates a tree structure from JSON data and generates a list of anchor tags which look like this: <a ng-click="shareParent(4619)">Some data</a> Despite associating the ng-click directive with the ...

What is the most efficient way to switch between different views in AngularJS while preserving the data in the views'

Every time I navigate from page1.html to page2.html in AngularJS and then return back to page1.html, my page model data disappears. Can someone please help me figure out how to preserve this data? I've looked at other questions on this topic but coul ...

Transmit a set of binary information and efficiently store it on the server's end

In my current project, I am utilizing AJAX to transmit an array of images to a server and save them on the server end seamlessly. My primary goal is to achieve optimal efficiency in this process, and I have come to realize that my present approach may not ...

Avoid creating a div within a Vue component

I am working on a Vue component that includes a div and a button, as well as two other components within separate divs. <script> export default { name: 'excursion-backend-component', methods:{ doRedirectio ...

Angular data binding is a concept that continues to elude me

After spending countless hours experimenting with variations of this code, it remains a mystery to me why one version works while the other fails. The situation is as follows: I am attempting to display a list of registered users retrieved from a database ...

Is it accurate to consider all JavaScript code and variables as inherent properties of an execution context?

It's worth considering that everything in JS code can be viewed as a property of an execution context, whether it's a global, function, or eval() execution context. Why is this the case? Each execution context has its own unique lexical and v ...

Utilizing Jade template helpers in both Node.js and the browser

When working with Jade templates in both an Express app and a browser environment, I find myself needing to format data before inserting it into inputs. Is it recommended to extend locals with similar functions in both Node.js and the browser? { formatDa ...

Importing a MATLAB table file into a Node.js environment and converting it into an array

Currently in the process of setting up a test server for a Web-Application, where fake data needs to be transmitted via a Websocket. The fake data is stored in a MATLAB table file (.mat), which essentially consists of a 4000*192 array. My goal is to conver ...

I am looking to set an HTML file as the homepage for my Next.js project

Is there a way in next.js to render a normal .html file (index.html) when someone visits my root directory at "https://example.com/"? I have researched and edited my config file as shown below, /** @type {import('next').NextConfig} */ const next ...

Remove rows that have values within a specific range

I'm facing an issue in Google Sheets where I'm attempting to delete entire rows on the "Data" sheet if any value in column B matches values from the range D3:E20 in the "Backend" sheet. The code provided works when a word is hardcoded as the cond ...

In Safari, the scrollbar appears on top of any overlays, popups, and modals

On my webpage, I have a div with the CSS property overflow-y: scroll. The page also features several popup modals and overlays. Strangely, the scrollbar of the div appears on top of these overlays instead of behind them. I attempted to resolve this issue b ...

Getting the current selected value of a drop down during an OnSubmit event of AjaxUpload when submitting via ajax can be achieved by accessing

When using the AjaxUpload option to upload files, I have a requirement to pass dynamic parameters into the action. The code snippet below demonstrates what I am attempting to do: $("#btnImportUtility_Upload").ajaxSubmit(function () { new AjaxUpload(&ap ...

Is there a more efficient alternative to using JavaScript JSON?

Is there a quicker method for writing this code efficiently? view = + data.items[ 0 ].statistics.viewCount view1 = + data.items[ 1 ].statistics.viewCount view2 = + data.items[ 2 ].statistics.viewCount document.getElementById("views").innerHTML = view ...

Encountering a 500 (Internal Server Error) while trying to insert data into the database through ajax

In the HTML code, I have a basic AJAX function that is triggered by a button press. The goal is to have the PHP script being called insert the JavaScript variable sent into a database. var myval = 'testuser'; // generated by PHP $.a ...

Stopping CSS animations at a specific point along the path without using timing functions can be achieved by implementing a targeted

Is there a way to pause an animation at the 50% mark for 2 seconds and then resume? P.S. The setInterval method is not recommended! function pauseAnimation() { document.getElementById("0").style.animationPlayState = "paused"; }; var pauseInterval = set ...