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 889373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:33:23+00:00 2026-05-15T13:33:23+00:00

I have the following: container.dialog().bind(‘dialogopen’, function(event, ui) { … if (someCondition) { $(this).dialog(‘close’); //

  • 0

I have the following:

container.dialog().bind('dialogopen', function(event, ui)
  {
     ...
     if (someCondition)
     {
         $(this).dialog('close'); // the dialog is not closed!
     }
  }

How I should make it work?

Unfortunately there is no ‘beforeopen’ event to be hooked.

  • 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-15T13:33:24+00:00Added an answer on May 15, 2026 at 1:33 pm

    The problem here is you need to bind the event before it happens. Currently you’re calling .dialog() which opens the dialog (unless autoOpen: false is a provided option). This means before your .bind(....) runs, the event already occured. The solution is to just bind before the event happens, like this:

    container.bind('dialogopen', function(event, ui) {
      if (someCondition) {
         $(this).dialog('close'); // the dialog is not closed!
      }
    }).dialog(); //.dialog() fires "dialogopen" as part of it's execution
    

    You can view a demonstration here, it’ll prevent the dialog from opening, or rather it does open, but instantly closes before the UI thread updates, so to the user, it never opened.

    This works because the dialogopen event is fired on the element you turned into a dialog (not the dialog container)…it doesn’t matter that the dialog itself is created later, this is just a DOM element listening to events.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function: (function ($) { $.fn.createCommonDialog = function () { this.dialog({
i have the following block of code: $(#contact_container form, #contact_details form).live( submit, function(event) {
I have the following function which creates a std::vector of iterators into another container:
I have the following code. $(document).ready(function() { $('#btnOpen').click(function(e) { $('#content').modal({ onOpen: function(dialog) { dialog.overlay.fadeIn('slow',
I have a container div with the following CSS: #container { position:relative; overflow:hidden; width:200px;
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
How would I setup my controls for the following situation?: I have a parent-container
I have the following text contained within a field in my DB: [quote:5a7b87febe=mr smith]This
I have the following code: $('#commonDialog').dialog({ autoOpen: false, modal: true, resizable: false, draggable: true,
I have small question regarding the following error: this.context.sourceCache On a custom control I

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.