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

Preserve a data point without causing any alterations

I am working with a device that continuously sends values until it is stopped. These values are then saved inside an array. deviceMonitoring( device2 ){ // In this function, I populate the arrayTimestamp and then copy the first value. this.arrayElement = t ...

Issues with Navigating through a Scrollable Menu

I'm having a difficult time grasping the concept and implementing a functional scrolling mechanism. Objective: Develop a large image viewer/gallery where users can navigate through images by clicking arrow keys or thumbnails in a menu. The gallery an ...

Observing a peculiar discrepancy in how various versions of JSON.stringify are implemented

Imagine having a deeply nested JS object like the example below that needs to be JSON-encoded: var foo = { "totA": -1, "totB": -1, "totC": "13,052.00", "totHours": 154, "groups": [ {"id": 1, "name": "Name A", " ...

What are some techniques for streamlining this code with Typescript?

I am currently working with the following code snippet: let doNavigate = this.currentScreen === removedFqn; if (doNavigate) { location.reload(); } Does anyone have any suggestions on how I can simplify this code using Typescript? ...

Creating customized meta tags with Vue Meta 3: A step-by-step guide

Just wanted to share my experience: "I decided to switch from vue-meta to @vueuse/head package found at npmjs.com/package/@vueuse/head and it works perfectly." I've implemented Vue Meta 3 for providing meta data to my website. The API documentation c ...

Implementing modifications to all HTML elements simultaneously

In my HTML document, there are around 80 small boxes arranged in a grid layout. Each box contains unique text but follows the same structure with three values: name, email, and mobile number. I need to switch the positions of the email and mobile number v ...

Creating audio streams using react-player

I am currently working on integrating the react-player component from CookPete into my website. However, I am facing a challenge in setting up multiple audio streams. Additionally, I want to include both DASH and HLS video streams but adding them as an arr ...

Ensure that a synchronous action is performed prior to each Backbone HTTP request

For each authenticated request (GET, POST, etc) in my Backbone/Marionette application, it is necessary to include an accessToken. The accessToken and expireDate are stored in the localStorage. To verify if the accessToken has expired, I utilize the metho ...

Tips for bundling a Vue Single File component using Vite for secure loading over HTTPS

I am in the process of compiling and packaging my Vue Single File component for distribution and dynamic loading via HTTP. After stumbling upon Markus Oberlehner's insightful article, I learned about using Vue CLI v3 with the command below: npx vue-c ...

How can I change an icon and switch themes using onClick in react js?

I have successfully implemented an icon click feature to change the colorscheme of my website (in line 21 and changeTheme). However, I also want the icon to toggle between FaRegMoon and FaRegSun when clicked (switching from FaRegMoon to FaRegSun and vice v ...

Original selection unavailable in pagination

I'm encountering an issue on my website where Bootstrap and JQuery don't seem to work well together. $("ul.pagination li:not(.active) a").on("click",function(){ $(".pagination li.active").removeClass("active"); $(this).parent().addClass("activ ...

The issue with linking to files on a custom 404 error page is that it doesn't function properly when

Having some trouble with my 404 page. I seem to have figured out the issue. The following URL works fine: sia.github.io/404.html and so does this one: sia.github.io/ooofdfsdfaablahblah However, when navigating to sia.github.io/1/2/3/, everything seems to ...

What could be causing Vue to cease functioning after rendering two pages in a cshtml file?

Coming from a very beginner level in programming, I am currently working on developing a website using asp.net MVC. However, after rendering a view page to _layout, the vue in the _layout suddenly stopped working and an error message appeared in the conso ...

Having trouble with the HTML5 canvas for loop not rendering the initial object in the array?

Essentially, I'm attempting to iterate through each letter in a text string (specifically the text "marius"). However, there's an issue where the first letter is not being displayed. When the text is "marius", only "arius" is drawn. I've exh ...

Run a Javascript function when the expected event fails to happen

I currently have this setup: <input type="text" name="field1" onblur="numericField(this);" /> However, I am struggling to figure out how to execute the numericField() function for the element before the form is submitted. I attempted using document ...

What is the best way to merge two JSON arrays using Axios in a React project?

I am currently working on getting data using axios React from Laravel, but I am facing some challenges in combining two arrays by their respective Ids. In my case, I am trying to retrieve product data and images from the Laravel Controller. Can anyone prov ...

The building of the module was unsuccessful due to a failure in the babel-loader located in the webpack module of Nuxt

While working on my Nuxt.js project, I encountered a warning error that I couldn't resolve even after searching for a solution. If anyone can assist me with this issue, it would be greatly appreciated. The error message is as follows: ERROR in ./.nu ...

Is it recommended to use new Vue() on each Blade or components?

Currently, I am diving into learning Vue.js and Laravel. As far as I know, a fresh Vue application is typically created in the app.js file by default: const app = new Vue({ el: '#app', }); Up to this point, my process has involved creating ...

Enhance user experience with jQuery UI sortable and the ability to edit content in real

I am facing an issue with jquery sortable and contenteditable. The problem arises when I try to use jquery sortable along with contenteditable, as the contenteditable feature stops working. After searching on Stack Overflow, I found a solution. However, up ...

Click once to expand all rows in the table with ease

I have successfully created a basic table using HTML. The table includes nested elements that are designed to open individually when clicked on the assigned toggle. Essentially, clicking on a '+' icon should reveal a sub-menu, and clicking on a & ...