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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:03:51+00:00 2026-05-16T21:03:51+00:00

There must be a cleaner way to do what i’m trying to do here…

  • 0

There must be a cleaner way to do what i’m trying to do here…

I have a jquery Ui dialog box that opens when i click on the eventClick handler in the FullCalendar plugin.

The dialog box contains the details of the event. On the bottom of the form there should be an edit button, that will close the dialog box down and open a new one with an editable form in it.

For the most part i’ve succeeded, in the sense that the edit button does indeed bring up the edit form in a dialog box. BUT it’s not a new dialog box, it’s the same dialog box from the first click, with the OK and edit buttons on it.

How do a i get a new dialog box to open for the edit form?

Below is the eventClick function

eventClick: function(event) {                  
                if (event.url) {                           
                     $('#details')
                       .load(event.url)
                       .dialog({                               
                           title: 'Event Details',
                           buttons: { "Ok": function() { $(this).dialog("close"); },
                                      "Edit": function() {
                                        $(this).dialog("close");
                                        $('#details').load('/Events/Edit/' + event.id)
                                                     .dialog({
                                                       title: 'Edit'
                                                           });                                                   
                                                       } }                                   
                            });                                
                        return false;
                    }
                },
  • 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-16T21:03:52+00:00Added an answer on May 16, 2026 at 9:03 pm

    I see two issues that may be causing your problems:

    1. dialog('close') merely closes the
      dialog, but doesn’t empty its
      contents. If you want to empty the
      dialog and return it to a clean
      state, you want to use
      dialog('destroy').
    2. You have several load() function calls strung together, but
      don’t have any callbacks. So your
      load that tries to load the content
      from /Events/Edit/eventID is
      fired, but then you immediately
      display the dialog again. The
      load() function has a callback
      parameter that will get executed
      when the content is returned from
      the url passed in to the load()
      function. This way, your dialog
      would display once the content has
      been received from the server.

    A way that I thought you could organize your code so that it’s a little more maintainable (but it also involves breaking out some of your anonymous functions into named functions) is below:

    eventClick: function(event) {
        if(event.url) {
            $("#details").load(event.url, loadDialog(event.id));  //call loadDialog once you get content back from your URL
        }
    }
    
    function loadDialog(eventId) {
        $("#details").dialog({
            title: "Event Details",
            buttons: {
                "OK" : function() { $(this).dialog("close"); },  //this just closes it - doesn't clean it up!!
                "Edit" : function() {
                    $(this).dialog("destroy");  //this completely empties the dialog
                                               //and returns it to its initial state
                    $("#details").load("/Events/Edit/" + eventId, loadEditDialog($(this)));
                }
            }
        });
    }
    
    function loadEditDialog(theDialogContainer) {  //this is a simple dialog display function -- could be inlined
        $(theDialogContainer).dialog({
            title: "Edit"
        });
    }
    

    I hope this helps! All the code above wasn’t tested, so there could be typos — it’s mainly pseudo-code to explain my reasoning. If there are questions, let me know and I’ll update my question accordingly.

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

Sidebar

Related Questions

I think there must be something subtle going on here that I don't know
I have a feeling that there must be client-server synchronization patterns out there. But
There must be a generic way to transform some hierachical XML such as: <element1
There must be an easy way to do this, but somehow I can wrap
There must be an easy way to do this. I build a Flex app
I assume there must be a system and language independent way to just stick
I know websphere does it, so there must be something that lets apache figure
Yes, There's More Than One Way To Do It but there must be a
Obviously I can do and DateTime.Now.After - DateTime.Now.Before but there must be something more
I'm sure this is a relatively simple question, and there must be a good

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.