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

  • Home
  • SEARCH
  • 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 7924279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:41:00+00:00 2026-06-03T17:41:00+00:00

I have a UI Dialog for View selection that is on almost every page,

  • 0

I have a UI Dialog for View selection that is on almost every page, so I moved it to an external js file.

It works perfectly on every page where it is called by click functions, but on one page, where I am trying to automatically open dialog depending on the value of a javascript variable, it fails.

Is this because when the external js file is loaded, the html of the dialog doesn’t exist? If I move the in the external back to the page, it works Ok.

Can anyone offer me a solution, I really would like to keep the View Dialog initialization code in the external files.

External js file

$(function() { // ******* The Views Dialog
  var $divViewDialog = $('#divViewDialog');
  $divViewDialog.dialog({ autoOpen: false, modal: true,title: 'Select required view'});
  ..... etc

Page code calling the dialog –

$(function() {

// ********* Other unrelated stuff

  if (ulx>1) { $divViewDialog.dialog('open');} // If logged in, Show View Dialog

  else {$divLoginDialog.dialog('open');}       // else show Login Dialog

});

  • 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-06-03T17:41:02+00:00Added an answer on June 3, 2026 at 5:41 pm

    Probably because they are both set to execute on document ready, if the second one executes first then the dialog wire up hasn’t actually happened yet. You should change the wire up to be a JavaScript function, then call said function in your page before opening the dialog.

    EDIT: Also, you’re putting the divViewDialog into a variable that is only accessible to the function in the page, so it won’t work in your external file. I have updated the code below to no longer use the divViewDialog variable.

    Try this:

    External JS File

    function wireUpDialog() {
        $('#divViewDialog').dialog({ autoOpen: false, modal: true,title: 'Select required view'});
        ..... etc
    }
    

    Page:

    $(function() {
        wireUpDialog();
        if (ulx>1) { $('#divViewDialog').dialog('open');}
        else {$divLoginDialog.dialog('open');}
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery modal dialog that displays a partial view. The partial view
I have a custom dialog with one editText view and two buttons ok and
I have a simple list view with some check boxes in an alert dialog.
I have a very simple dialog defined as: import android.app.AlertDialog; import android.content.Context; import android.view.LayoutInflater;
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have a dialog that I want to place within another dialog and position
I have a dialog box with controls that is popped up and when a
i have a dialog box that opens on pageload for a site. script type=text/javascript>
I have this nice dialog view I set my UserInputDialog class to: <LinearLayout android:id=@+id/LinearLayout01
I have dialog box with two controls: tree view and list box . 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.