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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:07:01+00:00 2026-06-17T08:07:01+00:00

Hey guys so in JQuery ui it produces a close link that once clicked

  • 0

Hey guys so in JQuery ui it produces a close link that once clicked it closes the dialog. My question is how to I close it out without using that button?

I have a terms of service that pops up and I need the decline terms link to be used instead of the close button generated from the ui.

So let me know how I go about doing this, thanks 🙂

EDIT:

I used the following code and no cigar – tells me Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method ‘close’

function decline(){

     $( '#decline' ).dialog( 'close' );

    }

Once the selector is clicked it has a onclick=”” which sends it here. The selector is a id=”decline”

Here is the entire code on my page which grabs the dialog –

$(function() {
        $( "dialog:ui-dialog" ).dialog( "destroy" );
    });
    function showUrlInDialog(url){
      var tag = $("<div></div>");
      $.ajax({
        url: url,
        success: function(data) {
          tag.html(data).dialog
          ({
              width: '100%',
                modal: true
          }).dialog('open');
        }
      });
    }
    function agree(){
        alert("Handler for .click() called.");
    }
    function decline(){

     $( '#decline' ).dialog( 'close' );

    }

Here is the selector that will initialize it –

<a href="#" onclick="showUrlInDialog('termsofservice.php'); return false;">link to page B</a>

Here is the selector that I WANT to close the dialog box –

<a href="#" onclick="decline();" id="decline"><span >I decline these terms</span></a>

Edit –

Here is new code I am using with no sucess:

function decline(){

     $( '#terms-container' ).dialog( 'close' );

    }

terms-container is the main div from the other file where the initilizer gets the data

  • 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-17T08:07:02+00:00Added an answer on June 17, 2026 at 8:07 am

    Since you need to close the dialog from somewhere else, I’d suggest creating a div which is there to take your html from the ajax call rather than creating it on the fly.
    Html:

    <a href="#" onclick="showUrlInDialog('termsofservice.php'); return false;">link to page B</a>
    <a href="#" onclick="decline();" id="decline"><span >I decline these terms</span></a>
    <div id="dialog-container"></div>
    

    Javascript:

    $(function() {
        $("#dialog-container").dialog( "destroy" );
    });
    function showUrlInDialog(url){
      var tag = $("#dialog-container");
      $.ajax({
        url: url,
        success: function(data) {
          tag.html(data).dialog
          ({
              width: '100%',
                modal: true
          }).dialog('open');
        }
      });
    }
    function agree(){
        alert("Handler for .click() called.");
    }
    function decline(){
    
     $("#dialog-container").dialog( 'close' );
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey Guys I am in the process of learning JQuery and I started using
Hey guys I have an ajax jquery function that receives data from a php
Hey guys quick question, I am sending a request with the jquery ajax function
Hey guys.. Quick question: I wrote a simple JS that opens lightBox for image
hey guys hope you can help me out. I am relatively new to jquery
Possible Duplicate: Get QueryString values with jQuery Hey guys, I got a question if
Hey guys I am pretty new to JQuery and I have a question about
Hey guys I'm working on a jQuery code snippet that's suppose to remove a
Hey guys, I'm new to jQuery/js and having a hard time figuring this out.
Hey Guys. I have got a problem on using the jquery auto-complete plugin.my problem

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.