Trouble with Vue bootstrap's <b-modal> function not triggering on @click event

Instead of passing props to the <b-modal> buttons, I want to directly call signinUser() method on @click in my modal when clicking the default OK button. However, the modal doesn't seem to respond to this.

The signinUser() method will trigger on @hidden event though.

I'm also looking to prevent the modal from closing unless a user is authenticated (which is why I don't want it triggered on @hidden).

Can someone guide me in the right direction?

Here's my component where firebase authentication is performed:

<template>
  <div class="container">
    <b-modal id="signinModal" @click="signinUser($event)" v-model="modalShow" :no-close-on-backdrop="true">
      <input id="email" v-model="email" placeholder="email">
      <input id="pass" v-model="password" placeholder="password">
    </b-modal>
    <form v-on:submit.prevent class="cube" v-if="modalShow == false">
      <div>
        <input id="title" v-model="title" placeholder="title">
      </div>
      <div>
        <textarea id="body" v-model="body" placeholder="body"></textarea>
      </div>
      <div>
        <b-button id ="postbtn" @click="addpost($event)" variant="outline-success">Publish</b-button>
      </div>
    </form>
  </div>
</template>

<script>
const { fb, db } = require('../../fireconfig.js')

export default {
  name: 'AddPost',
  data: function() {
    return {
      title: '',
      body: '',
      modalShow: true,
      email: '',
      password: ''
    }
  },
  methods: {
    signinUser(e) {
      e.preventDefault()
      fb.auth().signInWithEmailAndPassword(this.email, this.password)
        .catch(function(error) {
          // Handle Errors here.
          var errorCode = error.code;
          var errorMessage = error.message;

          if (errorCode === 'auth/wrong-password' || errorCode === 'auth/invalid-email') {
            alert('password or email incorrect', errorCode, errorMessage);
            //do nothing and keep modal open
          } else {
            console.log('user successfully authenticated')
            this.modalShow = false
          }
        });
    },
  }
}
</script>

Answer №1

Try substituting @ok for @click:

<b-modal id="signinModal" @ok="signinUser($event)" v-model="modalShow" :no-close-on-backdrop="true">
  <!-- more code -->
</b-modal>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve data from backend table only once within the bootstrap modal

How can I retrieve values from a table once a modal is displayed with a form? I am currently unable to access the values from the table behind the modal. Are there any specific rules to follow? What mistake am I making? I would like to extract the values ...

Ways to increase the date by one month in this scenario

I am facing an issue with manipulating two date variables. One of the dates is set to last Friday by default, and I am attempting to add a month to this date using the code snippet below. However, it does not produce the desired result. var StartDate = ne ...

What method would you recommend for modifying HTML text that has already been loaded using JSP?

Is there a way to update text on an HTML document without reloading the entire page? I'm looking to create a simple "cart" functionality with 5 links on a page. When a link is clicked, I want it to increment the "items in cart" counter displayed on th ...

The Node.js JSON string displays as "[object Object]" in the output

Front End // js / jquery var content = { info : 'this is info', extra : 'more info' } $.ajax({ type: 'POST', url: '/tosave', data: content }); Node // app.js app.post('/tosave', funct ...

What is the method for retrieving data from the root component within a child template in VueJs?

How can I access this.$root from within a VueJs template? For example: <template> <v-card elevation="this.$root.$refs.foo.cardElevation"> Foo </v-card> </template> I am aware that I can create a data property and ...

What is the best way to set up distinct Jest test environments for React Components and Backend API routes within NextJs?

In the realm of testing with NextJS, Jest comes into play effortlessly, complemented by React Testing Library for frontend testing. Interestingly, Jest can also be utilized to test backend code. Currently, I am incorporating a library in my API routes tha ...

Incorporating Vue.js components into PHP applications

I am currently working on a project using PHP in conjunction with Vue.js and vue-router. In my PHP form handler, I have implemented functionality to send emails. What I am trying to achieve is redirecting the user to a specific component within my Vue ap ...

Tips for integrating Croppie output into upload PHP and transferring the output to another PHP page

Looking to create an app that fetches images from Facebook SDK or via Ajax upload, crops them using croppie.js, and uploads them to my server directory. As a newcomer to Ajax, jQuery, and PHP, I stumbled upon a similar app on the internet that performs the ...

JavaScript plugin designed for effortless conversion of JSON data to structured HTML code

I want to add this JSON data to an HTML element. [ { "website":"google", "link":"http://google.com" }, { "website":"facebook", "link":"http://fb.com" } ] Is there an easy way to convert this using a plugin ...

Submit Button Not Responding on Mobile Device

I am facing an issue with my VueJs app. The contact form works perfectly on browsers, but when accessed from a smartphone or tablet, it fails to function properly. I have tried two different implementations to resolve the problem. Here is the first implem ...

"Fixing issue with Checkbox not getting checked using a combination of jQuery and

My array called `totalCheckBoxArray` contains the values [1, 2, 3]. I also have checkboxes with values 1, 2, and 3: <div class="card-body"> <h5>Document List</h5> <div class="form-check"> ...

What solutions are available for resolving the devServer issue in webpack?

Any help or advice would be greatly appreciated. I have configured webpack and everything works in production mode, but the webpack-dev-server is not recognizing static files and is giving the error "Cannot get /". How can I resolve this issue? Thank you i ...

jquery disable document manipulation function

I need to make some updates to a simple function that involves the current textarea. $(document).on("keydown", updated_textarea_var, function (e) { // do stuff }); To achieve this, I tried disabling the previous function and running a new one w ...

Displaying AngularJS content as text in an HTML file

I have been learning from the AngularJS Tutorial on Code School, but I'm experiencing an issue where my JavaScript code is not rendering properly in the HTML. Below is the snippet of HTML code: <html ng-controller="StoreController as store"> & ...

Is it possible for a React blog to be included in search engine results?

As I work on building my blog using React, Node.js, Express, Sequelize, and other technologies, a question has arisen in my mind: Will search engines index my articles, or will only the homepage of my site be noticed? For instance, if I have an article ti ...

Issue with the loop function

When I try to loop through my code, I keep getting the same "y" value (5) and it doesn't change. What I actually want is to make the ajax call repeat X times [all], passing both the response and the current call number through an anonymous function. A ...

Switch to a different form when clicked using JavaScript

Can you assist me with my code issue? The scenario is as follows: I have two forms - one for registration and one for login. I want to dynamically replace the login form with the register form when the user clicks on the "Sign up" link. Similarly, if the ...

Importing arrays from one file to another in JavaScript

Imagine you have a file named file1.js containing an array. var array = [data, more data, ...]; Are there any methods to access this array from another file? If not, what are the typical practices for managing a large array within a file? ...

Using JavaScript regex to substitute white spaces and other characters

Here is a string I need to modify: "Gem. Buitentemperatuur (etmaal)" I want to remove all spaces, capital letters, and special characters from the string so that it becomes: "gem_buitentemperatuur_etmaal" ...

Incorporating Redis within an Express route

My goal is to store a value in a specific key in one route: /api/foo?redisKey="1" (setting value for the key id=1) Then, in another route, I want to retrieve the value: /api/bar?redisKey="1" (getting value for key id=1) Since redis operates asynchronou ...