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

The Archive Base Latest Questions

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

I made a custom basic lightbox with Dojo to be used with forms and

  • 0

I made a custom basic lightbox with Dojo to be used with forms and data. Not really dealing with images or such.

The problem that I seem to be facing is this. When Dojo makes a call via AJAX to ajaxtb.php with specific code for example; ?f=login or ?f=register the page is loaded. When you I close the lightbox and try to view something different say ?f=stuff the lightbox will show what ever was before it be it ?f=login or what ever, it will show it until ?f=stuff is fully loaded.

Here is the code for the lightbox, also can some one tell me how to optimize it since its pretty redundant at the moment and very basic.

dojo.ready(function(){ 

    #loads logout confirmation      
    dojo.query("#jsLogoutPromp").connect("onclick", function(){

                                 dojo.byId("qpbox-title-text").innerHTML = "Logout Confirmation";

                                 dojo.query("#qpbox-content").style("display", "block");
                                 dojo.query("#qpbox-overlay").style("display", "block");

                                 dojo.xhrGet({
                                 url: "ajaxtb.php?f=logout",

                                 load: function(newContent) {
                                 dojo.byId("utm").innerHTML = newContent;
                                 },
                                 // The error handler
                                 error: function() {
                                 // Do nothing -- keep old content there
                                 }
                                 });

    }); 

    #loads options to upload profile photo
    dojo.query("#jsUserPhotoPromp").connect("onclick", function(){

                                 dojo.byId("qpbox-title-text").innerHTML = "Upload Photo";

                                 dojo.query("#qpbox-content").style("display", "block");
                                 dojo.query("#qpbox-overlay").style("display", "block");

                                 dojo.xhrGet({
                                 url: "ajaxtb.php?f=display_pic",

                                 load: function(newContent) {
                                 dojo.byId("utm").innerHTML = newContent;
                                 },
                                 // The error handler
                                 error: function() {
                                 // Do nothing -- keep old content there
                                 }
                                 });

    });     

    #closes everything when clicked well technically hides everything           
    dojo.query("#qpbox-close").connect("onclick", function(){


                                 dojo.query("#qpbox-content").style("display", "none");
                                 dojo.query("#qpbox-overlay").style("display", "none"); 


   });  

   #shows up for logout only, same as above code, but does not work since the original id is included in ajax.php?f=logout 
   dojo.query("#qpbox-stay").connect("onclick", function(){


                                 dojo.query("#qpbox-content").style("display", "none");
                                 dojo.query("#qpbox-overlay").style("display", "none"); 


   });  

});

The functions responsible for closing everything is qpbox-close and qpbox-stay. Technically both only hide the lightbox not close. The other problem is with qpbox-stay. qpbox-stay id is located in ajax.php?f=logout and when clicked it does not close the lightbox so not sure whats the problem with it.

here is the code for ajax.php

if($_GET['f'] == 'logout') {

echo '
<p>Are you sure you want to exit right now?</p>
<br>
<button type="submit">Logout</button>  <a href="#meminipost" id="qpbox-stay" onClick="return false;" style="float: right;">No, I wana Stay</a>
';

}

Thanks

  • 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-23T07:33:52+00:00Added an answer on May 23, 2026 at 7:33 am

    You can use dojo.empty(dojo.byId('utm')) before showing the lightbox to delete all the contents.

    Also, you can refactor your code quite a bit. Both click handlers do basically the same thing. So why not refactor them in a function?

    dojo.ready(function() {
      function showLightBox(title, url) {
        var utm = dojo.byId('utm');
    
        dojo.empty(utm);
    
        dojo.byId("qpbox-title-text").innerHTML = title;
        dojo.style(dojo.byId("qpbox-content"), "display", "block");
        dojo.style(dojo.byId("qpbox-overlay"), "display", "block");
    
        dojo.xhrGet({
          url: url,
          load: function(newContent) {
            utm.innerHTML = newContent;
          },
          // The error handler
          error: function() {
            // Do nothing -- keep old content there
          }
        });
      }
    
      function hideLightBox() {
        dojo.style(dojo.byId("qpbox-content"), "display", "none");
        dojo.style(dojo.byId("qpbox-overlay"), "display", "none");
      }
    
      dojo.connect(dojo.byId('jsLogoutPromp'), 'onclick', function() {
        showLightBox("Logout Confirmation", "ajaxtb.php?f=logout");
      });
    
      // ...
    
      dojo.connect(dojo.byId('qpbox-close'), 'onclick', hideLightBox);
    
    });
    

    You can try and connect to #qpbox-stay after you’ve loaded the content, or if using Dojo 1.6, you can use NodeList.delegate like:

    dojo.require('dojox.NodeList.delegate');
    dojo.query('#utm').delegate('#qpbox-stay', 'onclick', hideLightBox);
    

    That will connect to #utm which is already loaded, but work for #qpbox-stay only. It works with event bubbling, similar to jquery.live(). See http://davidwalsh.name/delegate-event

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

Sidebar

Related Questions

I made a custom control that is basically a multiline TextBox that allows input,
I made a custom handler that derives from MvcHandler. I have my routes using
I've made a custom DataGridViewCell that displays a custom control instead of the cell;
I have created a very basic custom layout to set out a menu made
I'm building an app where I use custom tableView Cells and i'm not really
I made a custom TObjectList descendant designed to hold subclasses of a base object
I made a custom task in my TFS build to examine my project's GlobalAssemblyInfo.cs
I made a custom master page. I also made a custom CSS file, which
I made a custom UITableView subclass and implemented this: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //
I made an custom UITableView. Then I made a custom header for sections. It

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.