Is there a foolproof way to determine when a dialogue box pops up on

I'm currently building an electron app using vue and Vuetify. I am able to create a modal using dialog, but I want to be able to modify certain elements within the dialog after it is displayed.

When using $refs, I cannot find the element before the dialog is opened. I am looking for a way to trigger an event when the dialog is shown, similar to the binding event show.bs.modal in Bootstrap. Is there a method to do this?

I have tried using $nextTick within the updated hook, but it triggers whenever other values are updated as well, making it less than ideal.

<v-dialog ref="alarmModal"> <-- working fine
  <v-card-text ref="alarmModalPrices" style="height:300px"> <-- undefined in methods or mounted
  </v-card>
</v-dialog>

<script>
export default {
mounted(){
  this.$refs.alarmModal.show = function () {  //<-- works correctly

   }
  this.$refs.alarmModalPrices.show = function () {  //<-- error

   }
},
updated () {
    this.$nextTick(function () {
      this.$refs.tempAlarmPrices.scrollTop = 50 // <-- works, but also triggered by other updates
    })
  }

Answer №1

Eventbus is essential for triggering events in my code. I'm still trying to grasp the concept of triggering events and manipulating their respective DOM elements.

<v-dialog ref="alarmModal" easer>
  <v-card-text ref="alarmModalPrices" style="height:300px">
  </v-card>
</v-dialog>
<script>
import { EventBus } from '../plugins/event-bus'
export default {
mounted(){
  this.$refs.alarmModal.show = function () {
    EventBus.$emit('fire') // <-- works
  }
}
updated(){
  this.$nextTick(function () {
      this.$refs.tempAlarmPrices.scrollTop = 300 // <-- works
      console.log(this.$refs.tempAlarmPrices.scrollTop) // returns 300
      var root = this
      EventBus.$on('fire', function () { // <-- triggered when event occurs
        root.$refs.tempAlarmPrices.scrollTop = 500 // <-- doesn't work
        console.log(root.$refs.tempAlarmPrices.scrollTop) // returns 0
      })
    })
}
}
</script>

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

Radio button triggers an ajax call once, but then fails to function

How can I troubleshoot an issue where the ajax function only works once when clicking on a radio button to change its value from 0 to 1, but not back to 0? The form contains a table with radio buttons for each record, and clicking on them triggers the aj ...

Navigating to a different page using the browser address bar causes the context to be reset

Upon receiving the user's data from the API on the login page, it is set in the user context. Subsequently, upon redirection to the AdminPanelApp, the data within the user context is displayed accurately. However, if I am in the AdminPanelApp and navi ...

What is the best way to send a JavaScript variable to Django using AJAX?

I am facing an issue while trying to pass an array in json format using ajax to my django views. Even though I receive a status of 200 indicating that the POST request has been successfully made, when I attempt to display the data passed in another templat ...

What is the best way to eliminate the input range in a React date range picker?

Here is an image illustrating a date range picker: https://i.stack.imgur.com/pwKaI.png I am looking to remove the labels for days before today and starting from today in the date range picker. How can I achieve this? Below is my code snippet: class Better ...

Trouble encountered while attempting to choose a single checkbox from within a v-for loop in Vue.js?

<div id="example-1"> <ul> <input type="text" v-model="searchString" placeholder="Filter" /> <p>sortKey = {{sortKey}}</p> <li v-for="item in sortedItems"> <input class="checkbox-align" type="checkbo ...

Guide on selecting every input field located within a table

My form is embedded within a table <form id="form"> <input type="submit" value="send" class="btn btn-w-m btn-primary" style="float: left;">Add transaction</input> <table class="table table-strip ...

An error occurs even before any Components are rendered, with a TypeError stating that the property 'type' cannot be read because it is undefined

I'm facing an issue with my Redux App where the first component (App.js) is not rendering due to continuous errors. The reducer mentioned below is being triggered at some point without any action, causing the compiler to interpret action as null and f ...

A clever method for implementing lazy-loading using mobx

Can you provide guidance on the most effective way to lazy load properties with MobX? I've been grappling with this issue for a few days now, and I've struggled to find suitable examples ever since strict mode was introduced. While I appreciate ...

Mongoose: Unable to fetch item using its specific identification - Error 404

I've been attempting to fetch objects from MongoDB using Mongoose, but I keep encountering a 404 error. router.get('/blogs/:id', function(req, res){ console.log('trying to get one blog post by id'); Blog.findOne({ _id: req.para ...

Steps to include a data-xx attribute in the displayed <table> within a Vuetify 2 v-simple-table

I am facing an issue where I want to include an HTML data-xxxx attribute to the HTML <table> within a v-simple-table. However, when I add the data attribute to the <v-simple-table>, it ends up being placed in a surrounding div two levels above ...

Error message 'require is not defined' can occur in Meteor.js when trying to incorporate an NPM package

I'm facing an issue while trying to utilize an npm package in Meteor.js (Release 0.6.6.3) by using Meteor.require. The error thrown states that require is not defined. What could be causing this and how can it be resolved? mrt add npm npm install git ...

Unit testing setTimeout in a process.on callback using Jest in NodeJS

I've been struggling with unit testing a timer using Jest within my process.on('SIGTERM') callback, but it doesn't seem to be triggered. I have implemented jest.useFakeTimers() and while it does mock the setTimeout call to some extent, ...

Iterating over an array of objects and executing asynchronous operations

I am currently working with NextJS and managing an array of assets (images) within my state. The task at hand is to post these images to the API. To accomplish this, I have a specific object that handles the posting process using the following syntax: let ...

Event follows activation of trigger click

I've already gone through this post on Stack Overflow about triggering an action after a click event, but none of the solutions I've tried so far have worked. Let's say I have a menu on my webpage like this: <ul class="nav nav-tabs"&g ...

What methods can be used to authenticate the user's input?

I am facing an issue with my program where it breaks if there is a space behind the last number entered. I want to prevent the function from breaking when a space is entered. I tried using $.trim but couldn't get it to work. I also attempted using an ...

Tips for updating the position on a website using AJAX

I am developing a website that pulls data from a MySQL database and showcases it on a map. How can I implement an automatic data refresh on the webpage every second? Should I incorporate my AJAX code within a timer function? Do I need to put the PHP scri ...

I am having issues with the external CSS and JS files not functioning properly in my project

I'm currently working on a project that has the following file structure: However, I am facing issues with loading my CSS and JS files... <link rel="stylesheet" href="./css/main.css"> <script src="./js/main.js" ...

I am interested in incorporating `connect-history-api-fallback` into my project in Vue.js, but I am unsure about the implementation

After refreshing the page in Vue.js, I encounter an Nginx error. I am currently using 'connect-history-api-fallback', but I'm uncertain about how to implement it in Vue.js. I noticed its usage in app.js with middleware server; how can we use ...

Is there a way to adjust a 5-minute countdown interval timer by 1 minute in a react JS application?

I am in need of creating a 5-minute interval timer using react JS, with a 1-minute offset. The current timer I have functions like this: 1:00 => 1:05 => 1:10 => 1:15 => 1:20. However, I require it to be adjusted to display: 1:01 => 1:0 ...

Develop a voice recording feature using ReactJS

In my quest to enhance a chat application with voice recording functionality, I came across the react-mic package. It worked smoothly and provided me with the data needed at the end of the recording session. (link: https://i.stack.imgur.com/nhNCq.png) Now ...