Choose a new image by confirming your selection with a dialog box

I have a collection of images displayed in a grid, and I want to be able to select one of them to update the value with the chosen image. Before proceeding with the update, I need a confirmation prompt to ensure the user wants to proceed or cancel the action.

How can I update the value of "this.backGroundUrl" in the following method with the newly selected image?

Image Grid:

    <v-col
      v-for="(asset) in assets"
      :key="asset._id"
      cols="4"
    >
      <v-img
        :src="getThumbnail(asset)"
        @click="confirmDialog = true"
      />
    </v-col>

Confirmation Component:

<ConfirmDialog
  v-if="confirmDialog"
  v-model="confirmDialog"
  @cancel="confirmDialog = false"
  @confirm="updatedBackgroundImage()"
/>  

Assets:

  computed: {
    ...mapState('assets', ['assets']),

Method:

 methods: {
    getThumbnail (asset) {
      return this.getMediaUrl(asset.thumbnailUrl)
    },
    getMediaUrl (url) {
      return process.env.VUE_APP_BACKEND_URL + url
    },
    updatedBackgroundImage () {
      // Need to set this.currentConnect.backGroundUrl to the selected image
      this.confirmDialog = false
    }

Answer №1

Make sure to save the URL before opening the dialogue box.

@click="displayDialog(asset)"
displayDialog(asset) {
  this.selectedAsset = asset
  this.dialogShown = true
}
updateBackgroundImage () {
  this.currentSelection.backgroundURL = this.selectedAsset
  this.dialogShown = false
}

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

I've been diving into webpack and experimenting with making an api call, but I'm hitting a roadblock. Let me share with you my code

This section pertains to the server const dotenv = require('dotenv'); dotenv.config(); // Setting up environment variables const express = require('express'); const bodyParser = require('body-parser'); const cors = require(&a ...

The video player will only start playing after the source has been changed if it was already in play

I am facing an issue with my video player that has thumbnails. The problem is that the video player does not start playing the selected video unless the video is already playing. This means I have to hit the play button first, and then select the thumbnail ...

The value of data in Vue.js remains stagnant even after reassignment

In my data setup, I have defined the following: data() { return { mdrender: '', markdown: '' }; }, Additionally, I am working with this function: methods: { interpretVars: function(markdown) { $.ge ...

What is the best way to track upload progress while using Django?

Is it possible to implement an upload progress bar for a website using Django? I'm interested in tracking the progress of file or image uploads but unsure how to accomplish this. Any tips on retrieving the upload status? ...

In what way does ReactJS enable me to utilize constant functions before they are declared?

I'm intrigued by the concept of using a value before defining it in ReactJS. Let's explore this through an example: function CounterApp() { const [counter, setCounter] = useState(0); const increaseValueTwice = () => { increaseValue() ...

Creating a Authentic Screw Top Appearance with CSS

I am striving to create a realistic screw head. Here is what I have done so far: <div class="screw"><div class="indent"></div></div> .screw { position: absolute; top: 10px; left: 49%; width: 30px; height: 30px ...

What is the best way to ensure that the search box automatically adjusts its position and size regardless of the screen resolution?

I'm currently working on a responsive website project and facing an issue with the absolute positioning of the search bar on the main page, which is crucial for me. Below is the code snippet: <div class="span4"> <form class="well form ...

Investigating TLS client connections with node.js for troubleshooting purposes

I am currently facing an issue while setting up a client connection to a server using node.js and TLS. My query revolves around how I can gather more information regarding the reason behind the connection failure. It would be great if there is a way to ob ...

Is there a way to verify the functionality of DigitalOcean features using doctl before transitioning to a live environment?

As a newcomer to using DigitalOcean Functions, I have set up some JavaScript namespaces using the doctl serverless command. My main query is regarding testing DigitalOcean functions locally before deploying them to production. Is there a way to do this wit ...

Issue occurs when trying to access the 'set' property of an undefined variable, leading to an error message stating "Cannot read property 'set' of undefined" while using 'this

I'm facing an issue while setting up basic cookies for my Vue project. When I try to set a cookie, I encounter the following error. My package.json file indicates that I am using vue-cookies version ^1.7.4. The error message occurs when I click the bu ...

How can I incorporate a script from the node_modules directory into a VueJS project?

Whenever a node_module is installed, the corresponding folder is automatically added inside the node_module directory of my application. Now, I am looking to include a script that resides within an installed module, such as .. installed_module/dist/ How d ...

Is your iPhone struggling to display animation sprites correctly?

After testing on Android and iPhone, I found that the website works great on Android but lags on iPhone. I suspected that the issue might be related to image preloading, so I tried adding a simple jQuery preloader, but it didn't solve the problem. Th ...

Ways to test the initial launch of an Android application using Cordova

I am developing an Android application using Cordova. My app consists of multiple pages, with the main homepage being index.html. I need to determine if it is the first time a user lands on the homepage after opening the app, regardless of how many times ...

Obtaining Vue view parameters using the sendFile() method in Express

Currently, I am in the process of developing a Node application that incorporates Express, Vue, and ThreeJS. In terms of the backend setup with express, here is what I have implemented: const app = express(); app.post('*', (req, res) => { ...

Guide on organizing an array of objects by the sub-part of their property values

Is there a way to order the elements in the given array based on a custom criteria related to the last 3 letters of 'prop2' in descending order? The specific order should be 'ABR', 'FDE', 'ZFR'. Another array needs t ...

Determining where to implement the API display logic - on the server side or

Currently, I am in the process of restructuring an API that deals with user profiles stored in one table and profile images in another. The current setup involves querying the profiles table first and then looping through the images table to gather the ass ...

What is the best way to cancel an interval set by a function within a functional component?

When using useEffect, it's easy to clear an interval like this: useEffect(() => { const interval = setInterval(some function, time); return () => clearInterval(interval) }) But what if I need to set an interval inside a function? Do I hav ...

Leveraging Polymer web components without the need for a package manager

I am looking to incorporate web components into a static web page without the need for any package manager or JavaScript build process. After referencing , I attempted to import them using unpkg by changing <script type="module" src="node_modules/@pol ...

Positioning divs around a circle can be quite challenging

Among my collection of divs with various classes and multiple child divs representing guests at a table, each main div symbolizes a specific restaurant table type. I have created a jsfiddle for demonstration. http://jsfiddle.net/rkqBD/ In the provided ex ...

Click on the sort icon in React JS to change its state

I need to update the sort icon in my table header when a user sorts a column. Here is the current implementation of my sorting function: var headerColumns = []; var IconType = 'triangle'; var IconSort = 'top'; var onToggleO ...