Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7005369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:20:32+00:00 2026-05-27T21:20:32+00:00

I am trying to get the Jquery UI modal dialog to take over after

  • 0

I am trying to get the Jquery UI modal dialog to take over after an autocomplete item is selected. I have everything popping up as excepted but there is code being ran after the modal dialog is up. In the end I want to have this dialog popup and react based on the button.

Select from auto-complete:

        select: function( event, ui ) {
        if(ui.item.squad != '0'){
            console.info('popup');
            var choice=null;

            $( "#dialog-confirm" ).dialog({
                resizable: false,
                height:140,
                modal: true,
                buttons: {
                    Cancel: function() {
                        choice = false;
                        $( this ).dialog( "close" );
                    },
                    "Move Shooter": function() {
                        choice = true;
                        $( this ).dialog( "close" );

                    }
                }
            });
            if(!choice){
                console.info($(this));
                $(this).text("");
                $(this).val("");
                $(this).attr("name", "");
                $(this).attr("value", "");
                console.info("false");
                return;
            }
        }

Most of the code has been taken from jquery ui here.

When I run this code I thought it would stop running code until a button was pressed but as you can see here the line that prints false to the console is printed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:20:32+00:00Added an answer on May 27, 2026 at 9:20 pm

    Your code wont work as it will execute that entire block and return. What you want todo is define a function that is executed once the user has made their choice. Essentially you would do this by moving the if statement you have under the dialog code to its own function and then call this function as part of your button handler code.

    Example:

    Define the callback somewhere:

    function handleDialogResponse(choice) {
        if(!choice){
            console.info($(this));
            $(this).text("");
            $(this).val("");
            $(this).attr("name", "");
            $(this).attr("value", "");
            console.info("false");
        }
    }
    

    Then change your dialog button code to something like this:

    buttons: {
        Cancel: function() {
            $( this ).dialog( "close" );
    
            handleDialogResponse(false);
        },
        "Move Shooter": function() {
            $( this ).dialog( "close" );
    
            handleDialogResponse(true);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two columns, each with many rows/divs. I'm trying to get jQuery UI
I'm trying to do a confirm dialog using jquery, but the form doesn't get
I'm trying to do some data entry via a jQuery modal Dialog. I was
All, I'm trying to send an email with the jQuery dialog modal window. I
I have a jQuery modal dialog that loads a different page on an iframe.
I'm trying to open a jquery modal dialog box when the user clicks on
I have a modal dialog (done through jquery UI) that submit a form to
i'm trying to create a modal dialog with jquery mobile rc2. I managed to
I am trying to get jquery validate to work on multiple fields. Reason being
I am trying to get jquery to pick up variable that I am defining

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.