Answer the question
In order to leave comments, you need to log in
Vue.js 2.x How to access an element that is hidden via v-if?
Good day.
I'm making a multi-step form (Django + Vue) with a lot of next step display conditions. I hide all subsequent steps (and options) with v-if, meaning they are not in the DOM after the page is fully loaded. Hence, a problem of the following order arose: I can’t make a call to such plugins as Flatpickr (beautiful date picker), for example.
Guru VueJS, tell me, please, what can be done with this? I've been struggling with this for more than a day..
ADD:
I'll explain a little about "what I want". On the fifth step of the form, there is a field (regular input
with the class .datepicker
) that the Flatpickr plugin is configured for. Its call is registered in the common script.js file (everything is collected by Webpack). So, the date picker is not displayed, because when loading the DOM there was no field with the class.datepicker
, since it only appears there in the fifth step.
Answer the question
In order to leave comments, you need to log in
v-show ?)
as an option to call plugins only after the condition for the block appears, and not when the module is loaded.
What's the problem with calling the plugin when you've shown the element? If you have a condition or a variable that is responsible for displaying the field, when it fires, then call the plugin.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question