question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use open() on vuejs

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] How to trigger open() on vuejs

Tell about your platform

  • flatPickr version : 4.0.0
  • Vue.js version : 2.1.10
  • Browser name and version : Chrome
  • This package version : 4.0.0

Current behavior NONE

Expected behavior Trigger flatpickr with custom button

Minimal reproduction of the problem with instructions Below is my code: Index.vue

<template>
<div>
<button @click="chooseBooking" class="btn btn-pink">Book Now</button>
</div>
</template>
<script>
    import flatPickr from 'vue-flatpickr-component';
    import 'flatpickr/dist/flatpickr.css';
    import 'flatpickr/dist/themes/material_blue.css'
    export default {
        components: {
            flatPickr
        },
        data(){
            date: new Date()
        },
        methods: {
                chooseBooking(){
                         // Trigger flatpickr
                }
        }
    }
</script

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ankurk91commented, Oct 30, 2017
<template>
<div>
<flat-pickr v-model="date" ref="datePicker"></flat-pickr>
<button @click="chooseBooking" class="btn btn-pink">Book Now</button>
</div>
</template>
<script>
    import flatPickr from 'vue-flatpickr-component';
    import 'flatpickr/dist/flatpickr.css';
    import 'flatpickr/dist/themes/material_blue.css'
    export default {
        components: {
            flatPickr
        },
        data() {
           return {
              date: new Date()
          }
        },
        methods: {
                chooseBooking(){
                         // Trigger flatpickr
                   this.$refs.datePicker.fp.open();
                }
        }
    }
</script>
0reactions
tambcommented, Nov 15, 2019

To access the flatPicker methods you need to add a ref to the <flat-pickr ref="myRef">.

Then access the ref this.$refs.myRef

And access the fp instance on that ref this.$refs.myRef.fp

And you can call .open() on that.

this.$refs.myRef.fp.open()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick Start - Vue.js
Quick Start #. Try Vue Online #. To quickly get a taste of Vue, you can try it directly in our Playground. If...
Read more >
Creating a Vue.js File Reader Component Using the ...
In this tutorial you'll learn how to use the FileReader API in order to load text from a file and how to style...
Read more >
Vue JavaScript Tutorial in Visual Studio Code
Put the cursor over the App , right click and select Peek Definition. A Peek window will open showing the App definition from...
Read more >
vue.js - Vue replaces "open" attribute to value "open" in any tag
I was using it along with jQuery, but you can easily substitute with vue.js' $el . This is what it looks in my...
Read more >
Getting Started with VueJS - Medium
You're in your first VueJS app! Our Project Files. Open your project directory your preferred text editor. Let's take a look at what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found