VueJS Hotel Reservation Datepicker: Trouble retrieving selected check-in date using event listener

I am new to VueJS and currently working on integrating the vue-hotel-datepicker into my project. I am having trouble figuring out how to utilize the checkInChanged event listener.

This is the code snippet from my template:

 <datepicker
     :startDate="startDate"
     :checkInChanged="setCheckinDate()" //issue arises here
     :maxNights="30"
     :disabledDates="bookedDates"
     :firstDayOfWeek="1"
     :i18n="lang"
     :showYear="true"
    >

  </datepicker>

The method in question:

 methods: {
     setCheckinDate() {
       console.log('test');
     }
 }

The challenge is that this event triggers even before a check-in date is selected. How can I properly implement this functionality and retrieve the selected date instance within my setCheckinDate() method?

UPDATE: Refer to my gist for the complete code. Following suggestions, I have switched the listener from :checkInChanged to @checkInChanged, but unfortunately, the event is not being triggered as expected.

Answer №1

checkInChanged is not a prop, it is an event. Therefore, you should use v-on:check-in-changed or @check-in-changed instead of :checkInChanged. Also, make sure to remove the () from the handler:

    <datepicker
        :startDate="startDate"
        @check-in-changed="setCheckinDate"
         ...

Update your method like so:

   methods: {
      setCheckinDate(newDate) {
        console.log(newDate);
     }
 }

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

Separate string by using a regular expression pattern

Looking to parse a dynamic string with varying combinations of Code, Name, and EffectDate. It could be in the format below with all three properties or just pairs like Code-Name, Code-EffectDate, or Name-EffectDate. {"Code":{"value":"1"},"Name":{"value": ...

Error in setting cookies using Javascript document.cookie on iOS with cordova-plugin-ionic-webview

Backend-sent cookies are successfully stored, but the app itself cannot set cookies. When running the code snippet below: document.cookie = "notified=1; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT"; console.log(document.cookie); An empty strin ...

Use map.fitBounds in MapBox to continuously adjust the map view to show only the visible features on the map

In my map, there are various features with IDs stored in an array called featureIds. Within my application, I have a button that can toggle the visibility of certain features. To address this toggling behavior, I am developing a JavaScript function named ...

Exploring SVGO CLI: A guide to inspecting SVGs across various directories

Currently, I am utilizing the SVGO CLI script to transform some icons within my project. Specifically, these icons are located in two separate folders - assets/icons/dark-mode and assets/icons/light-mode. My goal is to navigate through both of these folder ...

What is the best way to send a function or callback to a child process in Node.js?

In this scenario, imagine having a parent.js file with a method called parent var childProcess = require('child_process'); var options = { someData: {a:1, b:2, c:3}, asyncFn: function (data, callback) { /*do other async stuff here*/ } } ...

Retrieve and dynamically load an entire webpage using AJAX

Although it's typically not recommended, I am interested in displaying the progress of a download on a heavy page to show the user when it's ready. Is there a way for me to track and display the actual progress of the download? Can I monitor how ...

Selenium unable to interact with Javascript pop-up box

I am currently working on automating a feature for our web application, specifically a form of @mentioning similar to Facebook. On the front end, when a user types @ into a text input, the API is called to retrieve the list of users and display them in a b ...

Tips for configuring a function to only be called once, even when the page is reloaded

I'm currently facing an issue with making a Post request upon component Mount. Every time the user reloads the page or there's a change in state, the function gets called again due to the useEffect hook, resulting in multiple requests being sent. ...

angularjs: how to connect input date picker to parameters value

Having trouble with my datepicker input values not being passed as parameters in Angular and eventually to a C# parameter. Need help with setting up datepicker input and passing the values correctly. <div layout="column"> <md-content md-prim ...

The component data fails to reflect the updated value following a status change due to not properly retrieving the new result from the POST function

Below is the Vue.js 2 code snippet for sending data to the backend. The vuex library was used to manage the data status. After using the POST function, the result returned from the backend updates the value of sampleId. This value is auto-generated by the ...

Eliminate operation in React with the help of Axios

Within my React application, I have implemented a callback method for deleting data from an API using the axios library: deleteBook(selectedBook) { this.setState({selectedBook:selectedBook}) axios.delete(this.apiBooks + '/' + this.select ...

Exploring the Dynamics of AngularJS: Leveraging ng-repeat and ng-show

Recently, I came across this code snippet: <div class="map" ng-controller="DealerMarkerListCtrl"> <a ng-click="showdetails=!showdetails" href="#/dealer/{{marker.id}}" class="marker" style="left:{{marker.left}}px;top:{{marker.top}}px" ng-rep ...

Retrieve custom content from a database using Laravel and Ajax when clicking on a navigation bar

Recently, I've started working with Laravel 7 and AJAX. One of the features I want to implement is a 'product's name' navbar that displays product details in a div without refreshing the page when clicked. I came across a demo showcasin ...

Adjusting the dimensions of the cropper for optimal image cropping

I am currently working on integrating an image cropper component into my project, using the react-cropper package. However, I am facing a challenge in defining a fixed width and height for the cropper box such as "width:200px; height:300px;" impo ...

What could be the reason for the 'if' statement not being assessed in the 'then' promise of the ajax request?

I'm facing an issue with an ajax call in my code. I have a 'then' promise set up to handle errors, where the console log returns false correctly when there is an error. However, for some reason, the if condition in the next line is not being ...

Enhance your slideshows with React-slick: Integrate captivating animations

I recently built a slider using react slick, and now there is a need to adjust the transition and animation of slides when the previous and next buttons are clicked. I received some advice to add a class to the currently active slide while changing slide ...

Why are my cursor and my drawing line on opposite sides?

I've been working on a JavaScript drawing app, but I'm facing an issue where the drawn elements are not aligned with my cursor. The positioning seems off, especially when moving to the right or up on the canvas. As I move towards the furthest lef ...

Generate the Xpath for the mentioned href element to use with Selenium Webdriver

I need help creating the Xpath for a specific href element using Selenium webdriver with only IE browser. The HTML code I am working with is as follows: I am looking to find the Xpath for: . Can someone assist in generating the correct Xpath expression ...

The message from the XHR Object appears to be undefined, yet it correctly displays the status

I am currently working on an ajax call that is expected to return a 400 http error code. The backend language being used is PHP. Here is my PHP code: header('Content-Type: text/html',true,400); echo $this->upload->display_errors('< ...

Leveraging the array for fetching JSON data

I'm currently utilizing this code snippet to parse json data: $.getJSON(geocodingAPI, function (json) { // Extracting variables from the results array var address = json.results[0].formatted_address; console.log('Address : ', a ...