PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] Modal component VueJs with laravel

 January 19, 2022     laravel, vue.js     No comments   

Issue

I would like to remove something with a vuejs modal component and use a laravel route. So in my constructor, I have my destroy method. Someone can help me please ? I don't know how to proceed.

My modal vuejs component :

<template>
<button type="button" v-on:click="toggleModal()">Supprimer</button>
<div v-if="showModal"
     class="overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none justify-center items-center flex">
    <div class="relative w-80 my-6">
        <!--content-->
        <div
            class="border-0 rounded-lg shadow-lg relative flex flex-col bg-white outline-none focus:outline-none">
            <!--header-->
            <div
                class="flex pl-5 pt-5">
                <h3 class="text-lg font-medium">
                    Modal Title
                </h3>
            </div>
            <!--body-->
            <div class="relative pl-6 pt-4 flex-auto">
                <p class="text-lg leading-relaxed">
                    Voulez-vous vraiment supprimer ?
                </p>
            </div>
            <!--footer-->
            <div class="flex items-center justify-end p-6">
                <button
                    class="text-red-500 bg-transparent border border-solid border-red-500 hover:bg-red-500 hover:text-white active:bg-red-600 font-bold uppercase text-sm px-6 py-3 rounded outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
                    type="button" v-on:click="toggleModal()">
                    Annuler
                </button>
                <button
                    class="text-red-500 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
                    type="button" v-on:click="toggleModal()">
                    Supprimer
                </button>
            </div>
        </div>
    </div>
</div>
<div v-if="showModal" class="opacity-25 fixed inset-0 z-40 bg-black"></div>
export default {
name: "modal-component",
data() {
    return {
        showModal: false
    }
},
methods: {
    toggleModal: function () {
        this.showModal = !this.showModal;
    }
},

}

My template.blade.php :

<div id="app">
            <modal-component></modal-component>
        </div>

My app.js :

import Vue from "vue"

Vue.component( "modal-component", require("./components/ModalComponent.vue").default )

const app = new Vue({ el: "#app", });


Solution

You have to use axios package in vue js and make route in Laravel Side to handle that request and do your operation like Create, Edit, Show and Delete`

Axios Package you can make HTTP request to server from vue js



Answered By - Apurv Bhavsar
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing