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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:11:29+00:00 2026-05-18T04:11:29+00:00

I am using jQuery modal dialogs in my app to handle normal CRUD operations.

  • 0

I am using jQuery modal dialogs in my app to handle normal CRUD operations. In some cases I have even two stacked modal dialogs open.

I have then created two generic function in an external javascript file to handle respectively the showing and the submit of CRUD forms.

To show modal dialogs I call the following function

function _loadDialog(level, action, id, title, onCloseHandler) {
    var panel = panels[level];
    $(panel).dialog("option", "title", title);
    var url = action;
    if (id != "") url = url + "/" + id;
    $.ajax({
        type: "get",
        dataType: "html",
        url: url,
        data: {},
        success: function(response) {
            $(panel).html('').html(response).dialog('open');
        }
    });
    $(panel).unbind("dialogclose").bind("dialogclose", function(event, ui) {
        if (onCloseHandler != null) {
            onCloseHandler();
        }
    });
}

This function receive, among the others, a level parameter that instruct the function how to stack the dialog and where to place the rendered Partial markup returning back from the ajax call. This function works fine.

Inside the Partial View returned by the ajax call there are input and at the end the following code

<div style="text-align:right;">
    <input type="submit" id="btnSave" value="Salva" />
</div>

and, for the jQuery part, for example,

$("#contactForm").submit(function(event) {
    _submitForm(1, event, "#contactForm", "post", "html", '<%= Url.Content("~/Contact/Save") %>');
});

As you can see the submit function has the following signature

function _submitForm(level, event, formName, atype, adataType, aurl) {
}

and it handle

  • the form submission to the correct controller action
  • the user feedback (e.g. “action executed successfully”)
  • the dialog close operation

The level parameter is needed to address all the function, including closing the dialog, to the correct DIV panel used.

I would like to be able to show the same dialog sometimes as a dialog and sometimes as a sub dialog.
To be able to do this, I mean “logically speaking” as I am not so strong with javascript and jQuery, I need the following changes:

  • Modify the _loadDialog function to save the level parameter inside the dialog markup itself
  • Modify the _submitForm function and make it using the correct level parameter that has been previously saved from the _loadDialog function.

How can I achieve 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-05-18T04:11:30+00:00Added an answer on May 18, 2026 at 4:11 am

    I’m a little confused about what is where and when, but it seems that you want to associate a bit of information with a particular element.

    To do this, you can use jQuery’s .data() method. It will associate whatever data you want with a particular element.

    Not sure how exactly it should be used in your situation, but here’s a generic example:

    $('#someSelector').data('level', 3);
    

    Now the element with the ID someSelector will have the number 3 mapped to its 'level' attribute in its associated data.

    So to retrieve it, you would do this:

    $('#someSelector').data('level'); // returns 3
    

    When destroying an element that has data associated with it (this is just one example of such data), you should be sure to use .remove() or .empty() or one of the other methods that either automatically or manually removes the data.

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

Sidebar

Related Questions

I'm using jQuery and SimpleModal in an ASP.Net project to make some nice dialogs
I'm using jquery for modal dialogs. I want to open model dialog from one
Using jQuery, how would you find elements which have a particular style (eg: float:
I used Themeroller to generate an app theme and I am using jQuery and
I am working on a site that makes use of jquery modal dialogs to
Hi I am using jQm Window to load modal window. http://dev.iceburg.net/jquery/jqModal/#how i am trying
I am using jquery modal dialog, but the look of the dialog is other
I noticed that when I show up a modal dialog using Jquery UI in
I'd like to use a jQuery Modal Dialog of some kind to present 4
Using jQuery , how can I dynamically set the size attribute of a select

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.