Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue @change event not working in <b-form-datepicker/>

I am making a website that has a select form and datepicker form that sends an API request for data. I want to the update the data on every change of these forms, then a "submit" button is not required.

The select works perfectly by using the "@change", but this does not have any effect on the datepicker.

The template is.

<div class="d-flex flex-row flex-nowrap">
            <b-form-select v-model="region"
                           :options="regions"
                           class="select_box"
                           @change="get_data()"
            />
            <b-form-datepicker id="first_day_datepicker"
                               v-model="first_day"
                               :min="min_day"
                               :max="max_day"
                               class="mb-2"
                               @change="get_data()"
            />
            <b-form-datepicker id="last_day_datepicker"
                               v-model="last_day"
                               :min="min_day"
                               :max="max_day"
                               class="mb-2"
                               @on-change="get_data()"
            />
</div>

And the funtcion looks like this(simplified for example)

methods: {
        get_data() {
            console.log("Change data")
        },
}
like image 243
Baldvin Bui Avatar asked Feb 18 '21 00:02

Baldvin Bui


People also ask

Does bootstrap 5 have a Datepicker?

Bootstrap 5 Datepicker. Date picker is a plugin that adds the function of selecting time without the necessity of using custom JavaScript code.

Does bootstrap have a Datepicker?

As with bootstrap's own plugins, datepicker provides a data-api that can be used to instantiate datepickers without the need for custom javascript. For most datepickers, simply set data-provide="datepicker" on the element you want to initialize, and it will be intialized lazily, in true bootstrap fashion.


1 Answers

The <b-form-datepicker> control has no change event in its event list.

But it does have an input event which gets emitted when updating v-model:

<b-form-datepicker id="first_day_datepicker"
  v-model="first_day"
  :min="min_day"
  :max="max_day"
  class="mb-2"
  @input="get_data()"
/>
<b-form-datepicker id="last_day_datepicker"
  v-model="last_day"
  :min="min_day"
  :max="max_day"
  class="mb-2"
  @input="get_data()"
/>
like image 141
Dan Avatar answered Oct 09 '22 04:10

Dan