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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:52:02+00:00 2026-06-04T02:52:02+00:00

In my Index view I have a Create and Open template link: @Html.ActionLink(Create Template,

  • 0

In my Index view I have a Create and Open template link:

@Html.ActionLink("Create Template", "JsonCreate", "Template", new { id = "CreateTemplate" })
@Html.ActionLink("Open Template", "JsonOpen", "Template", new { id = "OpenTemplate" })

<script type="text/javascript">

   $(function () {
        $('#dialog').dialog({
            autoOpen: false,
            width: 300,
            resizable: false,
            title: 'Create Template',
            hide: "fade",         
            show: "fade",
            modal: true,
            open: function(event, ui) {               
                $(this).load("@Url.Action("Create")");
            },
            buttons: {
             "Save": function () {                      
                        var form = $('form', this);
                        $(form).submit();
                     },
                "Close": function () {
                    $(this).dialog("close");
                }
            }
        }); 

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

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

</script>

For the Open template link I want a pretty different dialog:

  • other buttons
  • other size
  • other title
  • etc…

What do I have to change that my open template link can open its own dialog using the same dialog div “#dialog”?

  • 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-04T02:52:04+00:00Added an answer on June 4, 2026 at 2:52 am

    I’ve tried re-using a single div for multiple different dialogs in the past and I highly recommend just creating a new div and a new instance of ui.dialog. It adds additional html at the bottom of the body tag, but this is a small price to pay for the benefit of clearly separating the javascript code. If you need different HTML inside the dialog div then there is absolutely no reason not to use two completely separate divs. Doing so will save you significant time and mental anguish.

    Should you choose not to heed this advice, I would recommend creating two config objects and destroying the dialog instance on close. Something like this:

    $(function () {
        var baseConfig = {
            autoOpen: false,
            resizable: false,
            hide: "fade",
            show: "fade",
            modal: true,
            close: function(event, ui) {
                $(this).dialog('destroy');
            },
            buttons: {
                "Save": function () {
                    var form = $('form', this);
                    $(form).submit();
                },
                "Close": function () {
                    $(this).dialog("close");
                }
            }
        }
        var createConfig = {
            width: 300,
            title: 'Create Template',
            open: function(event, ui) {               
                $(this).load("@Url.Action("Create")");
            }
        }
        var openConfig = {
            width: 500,
            title: 'Open Template',
            open: function(event, ui) {               
                $(this).load("@Url.Action("Open")");
            }
        }
    
        $('#OpenTemplate').click(function ()
        {
            var config = $.extend(baseConfig, openConfig);
            $('#dialog').dialog(config);
            return false;
        });
    
        $('#CreateTemplate').click(function ()
        {
            var config = $.extend(baseConfig, createConfig);
            $('#dialog').dialog(createConfig);
            return false;
        });
    });
    

    This is just one solution. There may be other ways to do this without destroying the dialog, but trust me when I say this will be much cleaner. Again, this div re-use solution assumes that the HTML inside the div does not change at all.

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

Sidebar

Related Questions

In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I have a view and template called index.html. I have a image which is
I have an Index View, where I got a form containing a partial view
I have an index view that I want to update automatically as the user
If I have a HomeController displaying its Index view, how would I proceed in
I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry
I have a view in a Django 1.4 project: def index(request): print reverse('menus_index') latest_menu_list
I have the following view: @model MyModel1 @{ ViewBag.Title = Index; Layout = ~/Views/Shared/_Layout.cshtml;
I have a listbox (detailed view). How do I get the index of the
I have a question on how to create custom View Helpers. I would like,

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.