Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
How to close bootstrap popup on submit in VUE

I am trying to hide a bootstrap popup when the "Add Location" button is pressed and when the field is filled.

<template>
  <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">{{popupTitle}}</h5>
        <button type="button" @click="closeModal" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p><input type="text" v-model="addBinLocation"></p>
        <span v-show="errorTxt" class="error">Field cannot be empty</span>
      </div>
      <div class="modal-footer">
        <button @click="btnAdd" type="button" class="btn btn-primary">Add Location</button>
      </div>
    </div>
  </div>
</div>



</template>

<script>
export default {
    props:['popupTitle'],
    data(){
      return{
        addBinLocation: '',
        errorTxt: false,
      }
    },
    methods:{
      btnAdd(){
        if(this.addBinLocation === ''){
          this.errorTxt = true;
        }
        else{
          this.$emit('addLocation', this.addBinLocation);
          this.addBinLocation = ''
          this.errorTxt = false;
        }
    },
    closeModal(){
      this.addBinLocation = ''
      this.errorTxt = false;
    }
  }
}
</script>

<style scoped>
  .error{
    color:red
  }
</style>

in the btnAdd function else section, when the user has filled the field, I want the modal to close when the button is clicked. I tried refs, by giving the modal a ref and adding this code but it is not working

this.$refs.myModal.hide()
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You could add a v-if="showModal" in your first modal div. And set this.showModal to true when the modal should be visible and set it to false when you want to hide the modal this.showModal = false

about 4 years ago · Juan Pablo Isaza Report

0

I have able to hide the popup by adding this in the addBtn function

 $('#staticBackdrop').modal('hide');
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!