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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:16:04+00:00 2026-05-23T20:16:04+00:00

I am trying to wirte a refresh condition if the jquery dialogs are not

  • 0

I am trying to wirte a refresh condition if the jquery dialogs are not open. Need fresh set of eyes as it does not seem to work. Code looks like that:

if(!$('#add_note-dialog').dialog("isOpen")) { 
    setTimeout(function() { location.reload() }, 3000);
}

The setTimeout function by itself works perectly, when I check the condition with firebug console, it shows proper status, but when I put it in <script> … it simply does not work or when I remove the “!” condition, it refreshes all the time even when the dialog is closed.

Any ideas?

  • 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-23T20:16:05+00:00Added an answer on May 23, 2026 at 8:16 pm

    The code in your question basically amounts to:

    • If the dialog is not open:
      • Schedule a page refresh in 3 seconds.

    I think you’re looking for:

    • Every 3 seconds:
      • If the dialog is not open:
        • Refresh the page.

    Or maybe even:

    • Every 3 seconds since page load or since the dialog was last closed:
      • If the dialog is not open:
        • Refresh the page.

    The first case can be implemented with setInterval():

    window.setInterval(function() {
        if (!$("#add_note-dialog").dialog("isOpen")) { 
            window.location.reload();
        }
    }, 3000);
    

    The second case is a little trickier, as it requires binding to the dialogopen and dialogclose events, and keeping track of the timer id, e.g. with data(). We also only need a one-shot timer since it will either fire and refresh the page, or be canceled, so setTimeout() will suffice:

    $(document).ready(function() {
        $("#add_note-dialog")
            // Set initial timer.
            .data("refreshTimer", window.setTimeout(window.location.reload, 3000))
            .dialog({
                /*
                 * Your dialog options,
                 */
                open: function() {
                    // Dialog open, cancel current timer.
                    window.clearTimeout($(this).data("refreshTimer"));
                },
                close: function() {
                    // Dialog closed, restart timer.
                    $(this).data("refreshTimer",
                        window.setTimeout(window.location.reload, 3000));
                }
            });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a materialized view in Oracle 11.1, which apparently does not
I need it so badly I have been trying it from 3 days but
When trying to setup a lock (pessimistic), with the following code: em.lock(controlnumbers, LockModeType.WRITE); em.refresh(controlnumbers);
I'm trying to add a css file depending on the browser width and not
jQuery(document).ready(function(){ // Set the data text var dataText = { name: 'John', time: '2pm'
I'm trying to refresh my memory but can't find answers with Google. public class
Need help trying to figure out why the button onCLick event isn't working. I
Im trying to use jquery and ajax to submit a form and show the
I'm trying write a query to find records which don't have a matching record
Trying to write a PowerShell cmdlet that will mute the sound at start, unless

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.