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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:46:01+00:00 2026-06-03T15:46:01+00:00

Having a jQuery dialog issue. I want to leverage ajax to render calendar content

  • 0

Having a jQuery dialog issue. I want to leverage ajax to render calendar content in a dialog window when a person clicks the the calDayContentEntry div. The following code works on the first click, but after closing the dialog I can no longer get the dialog to show again for that entry. Other entries work the first time as well, but secondary clicks will not open the dialog again.

Here is relevant code that I am having the issue with (all within the same asp.net mvc 3 razor view). Does anyone have some tweaks that could fix this issue?

           ...
           <div class="calDayContent">
            @foreach (var content in day.Contents)
            {
                <div class="calDayContentEntry">
                    <input type="hidden" value="@content.Entry.Id" class="hiddenId" />   
                    <div class="@content.DisplayClass">@content.Entry.Hours.ToString() hrs</div>
                </div>
                <div class="leaveRequestPopup"></div>
            }
            </div>
           ...

<script type="text/javascript">
    $().ready(function () {
        $('.calDayContentEntry').click(function () {
            getAndShowDialogContents(this);
        });

        // Register close event for dialog if overlay is clicked
        $('.ui-widget-overlay').live("click", function () {
            //Close the dialog 

            $currentDialog.dialog("close");
        });
    });

    function getAndShowDialogContents(entryDiv) {

        var entryId = $(entryDiv).find('input[type="hidden"]').val();
        var contentdiv = $(entryDiv).next('.leaveRequestPopup');
        var x = $(entryDiv).position().left + jQuery(entryDiv).outerWidth();
        var y = $(entryDiv).position().top - jQuery(document).scrollTop();

        $.ajax(
        {
            type: 'POST',
            url: 'Request/GetCalendarDetails',
            data: { id: entryId },
            success: function (result) {

                $(contentdiv).html(result);

                $(contentdiv).dialog({
                    autoOpen: false,
                    modal: true,
                    title: 'Details',
                    width: 400,
                    height: 300,
                    draggable: false
                });

                $(contentdiv).dialog("option", "position", [x, y]);
                $currentDialog = $(contentdiv).dialog('open');
            }
        });
    }
</script>
  • 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-03T15:46:02+00:00Added an answer on June 3, 2026 at 3:46 pm

    I think the weekend added a fresh perspective on the issue. The code that works is below. Basically, instead of using a popup div for every entry, I just used one div at the end of my page. That div is reused for every dialog. I use the global variable so I can refer to it when someone clicks outside the dialog to close it. Hope this helps someone else out.

               ...
                <div class="calDayContent">
                @foreach (var content in day.Contents)
                {
                    <div class="calDayContentEntry">
                        <input type="hidden" value="@content.Entry.Id" class="hiddenId" />
    
                            <div class="@content.DisplayClass">@content.Entry.Hours.ToString() hrs</div>
                    </div>
                }
                </div>
                ...
                <div class="leaveRequestPopup"></div>
                ...
    
    
    <script type="text/javascript">
        $().ready(function () {
            $('.calDayContentEntry').click(function () {
                getAndShowDialogContents(this);
            });
    
            // Register close event for dialog if overlay is clicked
            $('.ui-widget-overlay').live("click", function () {
                //Close the dialog 
    
                $currentDialog.dialog("close");
            });
    
            $currentDialog = $('.leaveRequestPopup').dialog({
                autoOpen: false,
                modal: true,
                title: 'Details',
                width: 400,
                height: 300,
                draggable: false
            });
        });
    
        function getAndShowDialogContents(entryDiv) {
    
            var entryId = $(entryDiv).find('input[type="hidden"]').val();
            var x = $(entryDiv).position().left + jQuery(entryDiv).outerWidth();
            var y = $(entryDiv).position().top - jQuery(document).scrollTop();
    
            $.ajax(
            {
                type: 'POST',
                url: 'Request/GetCalendarDetails',
                data: { id: entryId },
                success: function (result) {
    
                    $currentDialog.html(result);
    
                    $currentDialog.dialog("option", "position", [x, y]);
                    $currentDialog.dialog('open');
                }
            });
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having an issue where the my jquery UI dialog loads multiple times on
I'm having an issue with multiple jQuery UI dialogs. What I want is that
I'm tring to create a jquery ui dialog without having a empty div container
I am having issues loading a jQuery modal window upon submit. I want a
wish to ajax/refresh the current page after quitting a jquery dialog. I am having
I'm having some problems with Jquery UI Dialog and TinyMCE. Passing data to a
I'm having trouble getting the jquery ui 1.8 dialog to center I've tried leaving
I am having jQuery animation issues... I have a footer with a hidden div
I'm having two jquery's that I run and I want to combine them both
I'm working with forms inside jQuery Dialog, and am having some issues with the

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.