Difficulty closing Modal Popup when multiple Modals are displayed simultaneously

I am facing a challenge with transitioning between modal screens

When the button on the screen is clicked, Modal1 opens:

$modal.open({
    templateUrl: 'abc.html',
    controller: 'abcCtrl',
    size: 'lg',
    scope: $scope,
});

In Modal1, there is a Next button that, upon click, should close Modal1 and open Modal2:

$scope.validate = function(isValid) {
    if (!isValid) {
        $scope.errors = 'Please fill-up required fields';
    } else {
        $scope.errors = '';
        $modal.open({
            templateUrl: 'Payment.html',
            controller: 'PaymentCtrl',
            size: 'lg',
            scope: $scope,
        });
    }
};

In Modal2, there is another Next button that, when clicked, should close Modal2 and open Modal3:

$scope.placeOrder = function() {
        $scope.cart.abc().then(function(result) {
                $modal.open({
                    templateUrl: 'orderSummary.html',
                    controller: 'SummaryCtrl',
                    size: 'lg',
                    scope: $scope,
                    resolve: {
                        items: function() {
                            return result.data;
                        }
                    }
                });
            },
            function(err) {
                //error msg
            });
};

The issue arises when I add $modalInstance.close to Modal1. When opening Modal2 after closing Modal1, none of the buttons seem to work. Modal3 does not get opened as expected. The exact cause behind this behavior is unknown to me.

Any assistance or insight would be greatly appreciated. Thank you in advance.

Answer №1

Do you seek the wisdom of a sorcerer?

Check out this link

Answer №2

Start by initializing the Main Controller and opening Modal1. When Modal1 closes, execute the following:

 var modalInstance = $modal.open({
                templateUrl: 'xyz',
                controller: 'xyzCtrl',
                size: 'md',
                scope: $scope,
             });

            modalInstance.result.then(function(result) {
                  $scope.ghi();
              }, function(err) {
                //
            });

  $scope.ghi = function(){
     //open another modal 
    }

Invoke another function that will open yet another modal, continuing this pattern as 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

Replacing the yellow autofill background

After much effort, I have finally discovered the ultimate method to remove autofill styling across all browsers: $('input').each(function() { var $this = $(this); $this.after($this.clone()).remove(); }); However, executing t ...

Application experiencing server error when updating MongoDB data

I have encountered an issue while trying to update/modify data that has already been uploaded in a reactjs project using mongoDB as the database. Whenever I attempt to update the data, an error is displayed. How can this problem be resolved? https://i.sta ...

Alternate routing based on conditions in Angular

I've used the "$urlRouterProvider.otherwise('{route here}')" syntax in angular to create a catch-all route in Angular UI-Router. One thing I'm curious about is whether it's possible to have conditional "otherwise" routing based o ...

Enhance your webpage's body by zooming in using jQuery on Mozilla Firefox

I have a webpage and I would like to zoom its body when it loads using jQuery. However, the CSS zoom feature is not working in Mozilla Firefox. This is what I currently am using: $("body").css("zoom", "1.05"); It worked in Chrome, Opera, and Edge, but un ...

Struggling to implement a Rock Paper Scissors game using HTML, CSS Bootstrap4, and JavaScript, specifically facing challenges in getting the function to select a new image

Recently, in my coding class, we were tasked with creating a program that would display images of dice and generate random numbers when the refresh button was clicked. To practice using querySelector and setAttribute, I decided to expand on the lesson by i ...

The scroll animation feature was not functioning properly in Next.js, however, it was working flawlessly in create react app

I recently transitioned a small project from Create React App (CRA) to Next.js. Everything is working as expected except for the scroll animations in Next.js, which are not functioning properly. There are no errors thrown; the animations simply do not occ ...

Verify ngRoute route validity

In my application, I am utilizing angular-route to handle routing. While creating some links, I want to verify if the link is defined in routeProvider to prevent it from redirecting to the 404 page. Is there a method within ngRoute that allows me to conf ...

ngOptions accepts objects as values rather than just option values

I'm currently utilizing a 'getPickupSchedules' directive to populate schedules based on the inputted zip code provided by the user. Upon entering a 5 digit zip code, an $http.get request is made to fetch the schedules corresponding to that z ...

Tips for enabling autoplay for videos in Owl Carousel

I am facing an issue with implementing autoplay functionality for videos in an owl carousel. Despite trying different solutions found online, including this Owl Carousel VIDEO Autoplay doesn’t work, I haven't been able to make it work. Additionally, ...

Utilizing media queries to customize the appearance of a jQuery accordion widget

Hello, I'm struggling with implementing a jQuery accordion for mobile platforms that destroys itself on larger screens. While my code is mostly working, I've encountered two issues: The accordion only gets destroyed when the window is resized ...

Bringing life to web pages through captivating animations when showing and hiding div elements, utilizing the power

After extensive research on various online platforms, including stackoverflow, I unfortunately couldn't find a suitable solution to my problem. However, with the invaluable assistance of you all, I managed to successfully implement a code for my proje ...

How can we prevent users from changing URLs or accessing pages directly in Angular 7 without using authguard?

Hey there! I am trying to find a way to prevent users from accessing different pages by changing the URL, like in this scenario. Is there a method that can redirect the user back to the same page without using Authguard or any Modules? I have a StackBlit ...

Use a custom Angular directive to transform an HTML input field into a label

I have various input, textarea and select elements on certain pages (angular templates). My goal is to redefine the "input" directive so that it can take a parameter like ViewMode = true from either localStorage and convert all inputs into labels. If I cha ...

Issues with Angular 2 loading properly on Internet Explorer 11

We are currently running an Asp.net MVC 5 web application integrated with Angular 2. The application functions smoothly on Chrome, Firefox, and Edge browsers, but encounters loading issues on IE 11, displaying the error illustrated in the image below: ht ...

Web Security Vulnerability: Cross Site Scripting Detected

In our code, we are aiming to prevent XSS (Cross Site Scripting) attacks. However, the solution may involve a combination of JS (JavaScript) and HTML escaping, which could prove to be quite challenging. Below is a snippet that closely resembles our code: ...

How can you efficiently pass the index as a prop to a child component in React.js when dealing with arrays stored in

Just starting out with React, so bear with me if my terminology is a bit off. I'm working on a table that displays a list of people in a specific order. I want to be able to assign a this.props.tablePosition value based on the index of each person. t ...

Is there a way to deactivate other dropdown options?

To simplify the selection process, I would like to disable the options for "Province", "City", and "Barangay". When the user clicks on the "Region" field, the corresponding "Province" options should be enabled. Then, when a specific province is selected, t ...

Adjust the color of the Icon within the tab in Material-UI

I'm attempting to change the color of the tab icon that is highlighted while keeping the others unchanged, but I am struggling to find a solution. I am using a MUI component inside the icon button. <Tab icon={ ...

Choose a numeric value and then adjust it to display with exactly two decimal places

My goal is to create a code that achieves the following tasks: Add an ID to every nth child Round the number in each nth child to 2 decimal places Prefix the numbers with a pound sign (£) Loop through until all the nth children in a table are processed ...

Vue is alerting me that I cannot assign a reactive property to an undefined, null, or primitive value, specifically null

When retrieving data from Firebase, I am attempting to update the properties of the object being displayed on the UI. However, whenever I try to make any changes to the data, an error is thrown. Error in v-on handler: "TypeError: Cannot use 'in&apos ...