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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:54:44+00:00 2026-06-09T08:54:44+00:00

I am developing a web page which contains many jQuery dialogs . While my

  • 0

I am developing a web page which contains many jQuery dialogs.

While my code works in principal, I noticed it soon got “dirty”, and I feel a strong urge to clean up the code and make it more OO-like.

The main issues with my code are:

  • no dialog-specific state (i.e. set of variables)
  • no dialog-local event handlers
  • dialog-specific functions are global

Which approaches and solutions exist to make jQuery dialog more OO-like, as in Delphi and WinForms?

  • 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-09T08:54:45+00:00Added an answer on June 9, 2026 at 8:54 am

    Maybe the following can help you:

    • no dialog-specific state (i.e. set of variables)

    You can use data() to associate state with the augmented element, as with any element:

    $("#yourDialog").dialog({
        // your options...
    }).data("yourData", {
        some: "state",
        associatedWith: "thisElement"
    });
    

    • no dialog-local event handlers

    What you mean by dialog-local is not clear, but dialog widgets do emit events, and you can of course bind different handlers to events triggered on the inner elements of different dialog widgets.


    • dialog-specific functions are global

    They’re not actually global (they’re part of the $.fn namespace), but I understand having to call dialog() on the augmented element every time can be seen as unnecessarily heavy.

    That syntax, however, is only a bridge, a way to access the widget’s methods more suited to jQuery’s idioms. You can obtain a reference to the widget itself using, again, data(), then invoke its methods directly. For instance:

    $("#yourDialog").dialog("open");
    $("#yourDialog").dialog("close");
    

    Is equivalent to:

    var dialogWidget = $("#yourDialog").data("dialog");
    dialogWidget.open();
    dialogWidget.close();
    

    Update: From jQuery UI 1.9 onwards, the data() key becomes the widget’s fully qualified name, with dots replaced by dashes. Therefore, the code above becomes:

    var dialogWidget = $("#yourDialog").data("ui-dialog");
    dialogWidget.open();
    dialogWidget.close();
    

    Using the unqualified name is still supported in 1.9 but is deprecated, and support will be dropped in 1.10.

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

Sidebar

Related Questions

I am developing a web page code, which fetches dynamically the content from the
I'm developing web page which has main file index.php as follows: include('UserClass.php'); include('html/top.php'); $user
I am developing a web application which will be added as a custom page
I am developing a web page in which a rad grid displays the list
I am developing web pages which reference external links/images/stylesheets etc. I have 1 page
I am developing a simple web application which contains these 3 components: client that
I'm developing a web page in which I'm using Twitter's Bootstrap Framework and their
I am developing a web page on which I am accepting input words from
I'm developing a web site in which you can login from almost every page.
I'm developing a web page in Asp.Net 1.1 and have a DataGrid which allows

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.