Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vuetify open modal based on url anchor or #

/*
This code uses Vue, Vue Router to get the URL, and Vuetify for template components

It will check on load if there is an anchor point and if so opens the modal.
If you change the anchor point it will react to that and when modal is closed it will remove the anchor
*/

//---------
<template>
    <v-dialog v-model="modal_bool">
        <v-card>
            <p>This is the modal where I will display info!</p>
        </v-card>
    </v-dialog>
</template>

<script>
export default {
    name: "Modal",
    data: function () {
        return {
            modal_bool: false,
        };
    },
    watch: {
        "modal_bool"() {
            if (!this.modal_bool) this.$router.push({ path: this.$route.path })
        },
        "$route.hash": {
            immediate: true,
            handler() {
                if (this.$route.hash) this.modal_bool = true
                else this.modal_bool = false
            }
        }  
    }
};
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: js replace diacritics 
Javascript :: compare object array equals 
Javascript :: javascript include a js file from another 
Javascript :: buffer nodejs 
Javascript :: node powershell 
Javascript :: Appending the option element using jquery each function 
Javascript :: paragraph antd 
Javascript :: push to object javascript 
Javascript :: delete an element to an array 
Javascript :: array list in javascript 
Javascript :: ANGULAR locale fr 
Javascript :: js highest number in array 
Javascript :: express return svg 
Javascript :: date filter 
Javascript :: mongoose find get nested prop only 
Javascript :: javascript slice method 
Javascript :: Prevent safari loading from cache when back button is clicked 
Javascript :: kendo jquery grid refresh data 
Javascript :: regex negate 
Javascript :: sort array of strings 
Javascript :: mui date picker remove underline 
Javascript :: js group objects in array 
Javascript :: remove the .cache folder from angular 13 project 
Javascript :: append raw html javascript 
Javascript :: node express params 
Javascript :: convert a date range into an array of date in js 
Javascript :: remove duplicates from array javascript 
Javascript :: heroku buildpacks with react 
Javascript :: attributes in same line prettier 
Javascript :: how to check for enter keyPress in react native 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =