Is there a way to activate button A when button B is clicked in VueJS?

Xyz.vue

     <v-flex xs12 sm6>
            <v-btn class="changeNumberBtn" disabled @click="changeNumber()">Change Number</v-btn>
          </v-flex>

<v-btn round block color="green darken-3" dark large @click="generateCode">Proceed</v-btn>

At this moment, the Change Number button remains disabled. Is there a way to enable the Change Number button upon clicking the Proceed button?

Answer №1

Can you explain the function generateCode? If there is any specific logic involved, consider setting a boolean value like so:

generateCode() {
  this.updateButton = true
  // add your custom logic here
}

<v-btn class="updateNumberBtn" :disabled="updateButton" @click="updateNumber()">Update Number</v-btn>

Answer №2

To conditionally enable or disable a button, you can follow the example below.

var app = new Vue({
  el: '#app',

  data: {
    disabled: true,
  },
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <button  id="name" class="form-control" :disabled="disabled">Change Number</button>
  <button @click="disabled = !disabled">Continue</button>
</div>

Answer №3

To maintain a property in the data object, create a variable called numberDisabled. Start by setting it to true, then when the user clicks on Continue, toggle its value to false. Finally, in the changeNumber button, set the disabled attribute to this variable.

<v-flex xs12 sm6>
    <v-btn class="changeNumberBtn" :disabled="numberDisabled" @click="changeNumber()">Change Number</v-btn>
</v-flex>

<v-btn round block color="blue darken-3" dark large @click="numberDisabled=false;">Continue</v-btn>

As an example, I am updating the variable on @click, but you could also include it inside the generateCode method if needed.

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

Express is unable to locate the specified property

Here is my controller code snippet: exports.showit = function(req, res){ res.render('showpost', { title: req.post.title, post: req.post }) } In my post model, I have included title and name objects: title: {type : String, default : &apos ...

Leveraging the package.json file for client-side packages, enabling them to be dynamically loaded in the browser

Considering expanding the structure of package.json to incorporate dynamic package (plugin) loading on the client side. I am curious about how this idea aligns with the vision of npm. Essentially, I am interested in loading multiple modules with shared met ...

Have you ever encountered issues with Promises.all not functioning properly within your vuex store?

I'm currently experiencing an unusual problem. In my Vue project, I have a Vuex store that is divided into different modules. I am trying to utilize Promise.all() to simultaneously execute two independent async Vuex actions in order to benefit from th ...

Difficulty in displaying YQL JSON Results with HTML/JavaScript

When utilizing the subsequent YQL query along with XPATH to retrieve data from certain elements on a webpage: select * from html where url="http://www.desidime.com" and xpath='//h5[@class="product_text"]' I am attempting to showcase the outc ...

I am facing an issue where the data is not being populated in my form even though I am using ng

Here is a form with grouped inputs using the ngModelGroup directive: <form #form="ngForm" (ngSubmit)="submit(form.value)"> <fieldset ngModelGroup="user"> <div> <label>Firstname:</label> < ...

Is there a way for me to automatically close the navbar by clicking anywhere on the body of

Here is the structure of my navigation bar: <div id="mySidenav" class="sidenav"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a> <span ...

Create custom dynamic asset tags in AngularJS inspired by Mixture.io's features for seamless HTML templating

Curious about the potential for creating dynamic asset tags within Angular and, if so, the method to achieve this. Here's the backstory: I've been utilizing Mixture.io for templating and have become accustomed to its seamless and adaptable natur ...

Stopping an endless loop in JavaScript by pressing a key on the keyboard can be a useful

I've been working on creating a JavaScript game and am currently tackling the challenge of implementing gravity. One crucial aspect I need to address is creating an infinite loop without causing the browser to crash. Is there a way for me to include a ...

AngularJS - Customizing the dropdown selection in Bootstrap

I am encountering an issue with setting the selected dropdown value from the server. <select **class="form-control input-sm"** placeholder="Choose Email" ng-model="groupForm.email" ng-options="agentListl.email for agentListl in agentList track by ag ...

Issues with responsiveness and calculated attributes in Vue 3 using the Composition API

Within this menu, there are different items: Item 1 (marked as number 1 in orange) with the path: http://localhost:8080/#/documents Item 2 (marked as number 2 in orange) with the path: http://localhost:8080/#/documents/1 Item 3 (marked as number 3 in or ...

Whenever I use NextJS's <Link> component, I always end up getting redirected to a

After searching online, I came across this question and tried to implement the suggested solution, but it's still not working for me. Apologies for any duplication. I have a simple link tag that is resulting in a 404 error: <Link className={classe ...

Displaying the error message "No results found" in PHP AJAX live search with multiple values is not possible

I recently went through a tutorial on Most of it worked smoothly after setting it up on my local machine. However, I encountered an issue when searching for data not present in my database. I expected to receive an error message stating "No result found o ...

showing console logs before initializing preferences may lead to inaccurate results

My Content Management System (CMS) is WordPress. Recently, after making some changes, I encountered an error on a specific page: An error occurred: loading pref showConsoleLogs before prefs were initialised, leading to incorrect results being displayed - ...

Using Jquery to manipulate arrays based on options selected from a dropdown menu

I am currently working on a feature that suggests tags based on the selected category. This involves using a select box to choose a category and then displaying sub-categories in a list. Here is the current setup: <select id="categorySelect"> < ...

Are MobX Observables interconnected with RxJS ones in any way?

Is the usage of RxJs observables in Angular comparable to that in React and MobX? I'm struggling to find information on this topic. ...

Trouble with AJAX GET request functionality

I am new to AJAX and attempting to make my first AJAX call. Here is the code I have so far: $.get( "validate.php", { 'userinput':'x'}, function(response) { if( response.status ) alert( "Matches found" ); else alert( "No matches ...

Using w3-include-html with a relative URL path

Is there a way for me to use the same header HTML on multiple pages within subdirectories without having to duplicate the file itself? As shown in the code snippet below, the header file is located in both the current directory and parent directory. While ...

What is the best way to streamline the creation of a "products filter" using Node.js and Angular?

I have decided to build an angular application for an online computer store, and I am using a node/express backend. One of the key features of the application is the products page, where users can view all the products available in our database. Each produ ...

obtaining pictures from information obtained in vuejs

Trying to showcase images in my code that are already stored in my data like this: <div > <tr v-for='(ships,index) in destroyedShipBox' :key='index'> <td>{{ships}}</td> ...

Effective ways to resolve the ajax problem of not appearing in the console

I am facing an issue with my simple ajax call in a Java spring boot application. The call is made to a controller method and the returned value should be displayed in the front-end console. However, after running the code, it shows a status of 400 but noth ...