How can we reset the radio button to its previous value when the user selects "No" from the confirm dialogue box?

I'm facing an issue where I need to prompt the User confirmation box when they make a selection on the radio button.

While I have successfully triggered the Confirm Box, I am struggling to store the previous value in the radio group. Does anyone have any suggestions on how to achieve this? I have tried solutions found on Google but without success.

Ext.define('CustomRadioField', {
override: 'RadioField',
setListeners: function(config) {
    var me = this;
    config.listeners = {
            change: {
                fn: function(control, newValue, oldValue, eOpts) {
                    var me = this;
                    me.fieldChanged();
                    Ext.Msg.confirm(MyFunction.T('Confirm'), "Are you sure want to delete?", function(btn) {
                        if (btn == 'no') {
                            //Added my logic to reset back
                            control.suspendEvent('change');
                            control.setValue(oldValue);
                            control.resumeEvent('change');
                            //End
                           //Added to refresh page not to reload but this location.reload post to my server insted to refresh.
                            location.reload();
                        }
                        if (btn == 'yes') {


                        }
                    });

                }
            },
            scope: me
        },
        focus: {
            fn: me.storeFocusField,
            scope: me
        },
        afterrender: {
            fn: function(f, e) {
                me.setFieldFocus;

            },
            scope: me
        },
        boxready: {
            fn: me.setUpChangeEvent,
            scope: me
        },
        specialkey: {
            fn: function(f, e) {
                var me = this;
                switch (e.getKey()) {
                    case e.TAB:

                        break;
                }
            },
            scope: me
        }
};
},

});

Any insights would be greatly appreciated.

Answer №1

Could you please provide the code?

To reset a field value, you have two options: you can use the field.reset() function for radio button fields, or you can utilize the form.reset() method to revert all form fields back to their original state before any user changes were made.

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

Creating a basic Angular 1 application from scratch

Currently, I am in the process of setting up a small application with Angular 1 to enhance my skills (yes, we are still using version 1 at my workplace and I want to familiarize myself with it). Most of the application is working fine, but as soon as I in ...

Capture a fragment of a scene and convert it into a unique texture using THREE.JS

I'm interested in creating a texture of a specific area in my scene, similar to the example shown in the official documentation for three.js framebuffer here. As I examine the code provided, there's one particular aspect that's unclear to me ...

Triggering the browser to prompt the "Save As" dialog box when initiating a file download

After researching extensively on this particular topic, I have come to realize that none of the solutions available meet my requirements. What I am trying to achieve is to instruct my WinCE 6.0 board to generate a backup file via an AJAX request and then s ...

The NonErrorEmittedError message indicates that component lists rendered using v-for must include explicit keys

Upon executing the command gulp --ship, an error message appears in the terminal: NonErrorEmittedError: (Emitted value instead of an instance of Error) <app-Player-List v-for="player in players">: component lists rendered with v-for should have ...

The error message "Unable to retrieve property 'commands' of undefined (discord.js)" indicates that the specified property is not defined

As I try to incorporate / commands into my Discord bot, I encounter a persistent error: An issue arises: Cannot read property 'commands' of undefined Below is my main.js file and the problematic segment causing the error: Troublesome Segment c ...

What sets srcset apart from media queries?

Can you explain the contrast between srcset and media query? In your opinion, which is more optimal and what scenarios are ideal for each? Appreciate it! ...

Incorporating tawk.to into a Nuxt/Vue application

Has anyone had success implementing tawk.to in a Nuxt application? I took the initiative to create a file called "tawk.js" in my plugin folder and added the following code: var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date() (function () { ...

The error message "Unable to iterate over undefined property in Node.js using EJS and JavaScript" popped up

I've been struggling with the error "Cannot read property 'forEach of undefined" for two days now and I just can't seem to figure out the problem. Any help would be greatly appreciated. Here is the code: bruidstaart.js page where I am tryin ...

Employing an assortment of data points within a manufacturing facility

Currently, I have a factory that utilizes a JSON file wrapped in a $http.get request for testing purposes. However, this approach is not suitable when working within a SharePoint environment where JSON files are restricted. In the end, the goal is to integ ...

Incorporate form checkboxes with the image's title preceding them within every individual div

Is there a way to dynamically add a form checkbox to each of these divs with incrementing id's? My current setup is as follows: <div class="img-wrap"> <img title="1" src="img.jpg" /> </div> <div class="img-wrap"> < ...

Optimal utilization of JSON in JavaScript API: Enhancing Performance, Reinforcing Maintainability, and Optimizing Resources

Currently, I am working on developing an application using Laravel and VueJS (along with Vuex). Although I do not have much experience in working with these frameworks or front-ends, I am curious to know the best practices for utilizing the data received f ...

What is the best way to combine elements in an array of strings using commas between each item, but using "and" before the last item?

I have a collection of phrases that looks like this. ['white t-shirt', 'blue jeans', 'red hat', 'brown glasses'...] I am looking for a way to insert these phrases into the text below, separated by commas, with the w ...

problems with using includes() in the array every() method

Hi everyone, I've been spending quite a bit of time trying to find a solution to this problem and I'm hoping someone can help me out. The issue at hand is that I have 2 arrays - one containing multiple words from an address and another built wit ...

What is the best way to distinguish between relative blocks and convert them to absolute positioning?

What is the best way to locate relative blocks and convert them to absolute position while keeping them in the same place? Is this something that can be achieved using JavaScript or jQuery, or is it simply not possible? Thank you very much. ...

What is the best way to send data to PHP while moving objects between different div elements?

I have a situation where I have two parent divs containing dynamic children divs, and I want to enable POST requests to PHP when items are dragged from one side to the other (and vice versa). Here is the Javascript code I am using: function allowDrop( ...

Begin the Wordpress AJAX Login

Is there a way to trigger the code below when a user is logged out from another location due to user inactivity, similar to how wp-admin displays an AJAX login overlay if a user is logged out? I have not come across any documentation or tutorials on achiev ...

JavaScript code to obscure

My goal is to create a JavaScript function where the "costCenter" object starts with visibility set to false. However, when the user clicks on the "computer" item in a dropdown list, the visibility of "costCenter" should change to true. This is my current ...

Anticipating the arrival of various ajax outcomes within the onsubmit function

I'm struggling to grasp how I can effectively wait for the results of multiple functions that involve ajax requests. I experimented with using Promise.all() and $.when().done();, but found them complicating my code rather than simplifying it. I also ...

My ReactNative Android application is experiencing significant lag, is there anyone who can assist me in resolving this issue?

Currently, I'm tackling a reactnative android app project and have noticed a significant drop in performance. Unfortunately, I am clueless about the root cause of this issue. Could it be related to the navigator or are there other underlying factors a ...

Developing TypeScript applications often involves using JavaScript callbacks in order

I'm encountering some challenges implementing a JavaScript callback with namespace in a TypeScript file. I initially believed that I could directly copy JavaScript code into TypeScript, but Visual Studio's compiler is throwing multiple errors. D ...