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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:34:04+00:00 2026-06-08T18:34:04+00:00

I just started working with Jquery and I was wondering if there is a

  • 0

I just started working with Jquery and I was wondering if there is a way to reuse a dialog for multiple ids. I’m using the dialog to display a more indepth description of multiple items. The way I have the code setup right now is:

            $('#NY7C').dialog({
                autoOpen: false,
                width: 800,
                height: 700,
                modal: true,
                draggable: false
            });

            $('#NY7C-open').click(function(){
                $('#NY7C').dialog('open');
                return false;
            });

            $('#NY7R').dialog({ //another dialog that has the same features as #NY7C
            });

            $('#NY7R-open').click(function(){
            })

Inside the body I use the following code to open the dialog:

<a id="NY7C-open" class="ui-state-default ui-corner-all" href="#">More Info</a>
<a id="NY7R-open" class="ui-state-default ui-corner-all" href="#">More Info</a>

Finally, the information shown in the dialog is in:

<div id="#NY7C">
    //Information for NY7C
</div>
<div id="#NY7R">
    //Information for NY7R
</div>

Now the way I have the code right now works. However, I was hoping I would be able to reuse the first code so I can use it for multiple IDs(ex. NY7C, NY7R, NY7P, etc.). Is there any way to do this?

  • 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-08T18:34:06+00:00Added an answer on June 8, 2026 at 6:34 pm

    Give them classes instead of ids. For example:

    <a id="NY7C-open" class="dialog-trigger ui-state-default ui-corner-all" href="#">More Info</a>
    <a id="NY7R-open" class="dialog-trigger ui-state-default ui-corner-all" href="#">More Info</a>
    
    <div id="#NY7C" class="my-dialog">
        //Information for NY7C
    </div>
    <div id="#NY7R" class="my-dialog">
        //Information for NY7R
    </div>
    

    And the js would be:

    $('.my-dialog').dialog({
        autoOpen: false,
        width: 800,
        height: 700,
        modal: true,
        draggable: false
    });
    $('.dialog-trigger').click(function(){
        var id = this.id;
        var targetId = id.replace('-open','');
        var $target = $('#' + targetId);
        if($target.length){
            $target.dialog('open');
            return false;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using the jquery swfupload plugin and I have everything working besides
I just started using jQuery, but i can't get it working. On the index.php
Just started working with Mercurial a few days ago and there's something I don't
I just started working using Google Maps API yesterday, and trying to set up
I just started working with play, and I modified the way I'm doing a
I'm working on an MVC3 project right now and just started using SignalR. I
I just started working with jQuery and I have been searching for some type
I have just started working in jQuery and ASP.NET MVC. I want the same
I have just started looking into jquerymobile, done simple samples using jquery.mobile-1.0a1 . I
I'm fairly new to jQuery and just started working with jqGrid. I've looked over

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.