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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:17:04+00:00 2026-05-26T02:17:04+00:00

I have a dialog form that pops up and its content is loaded using

  • 0

I have a dialog form that pops up and its content is loaded using the jQuery load function. On that ajax loaded page there is a jQuery UI datepicker and in the Model that I pass to the view, I have MinDate and MaxDate properties that are used to set the min and max dates of the datepicker. On a non-ajax page I usually do something like this:

<script type="text/javascript">
$(function () {
     var model = @(Model.ToJson());

        $('.date').datepicker('option', 'minDate', new Date(parseInt(model.MinDate.substr(6))));
        $('.date').datepicker('option', 'maxDate', new Date(parseInt(model.MaxDate.substr(6))));

});
</script>

The problem is that if I include any javascript in the view that is loaded from the jQuery load function, it is stripped out and not executed. So, if I included the above code to specify the min and max dates for the datepicker in the dialog form doesn’t work.

How can I specify min and max dates for a jQuery UI datepicker where the datepicker is being loaded via ajax and the min and max dates come from the model?

  • 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-26T02:17:05+00:00Added an answer on May 26, 2026 at 2:17 am

    You could serialize those two model properties as HTML5 data-* attributes somewhere in the DOM. For example as part of the datepicker itself it would be great:

    <input type="text" class="date" name="myDate" data-min="@Model.MinDate" data-max="@Model.MaxDate" />
    

    and then define some functions:

    function initPicker() {
        $('.date').each(function() {
            $(this).datepicker('option', 'minDate', $(this).data('min'))
                   .datepicker('option', 'maxDate', $(this).data('max'));
        });
    }
    

    and then invoke this function in your DOM ready:

    $(initPicker);
    

    as well as in your AJAX success callbacks in order to reattach them.

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

Sidebar

Related Questions

(VS2005, .Net 2.0) I have a form that is displayed as a dialog using
I have a form that is being serialized by JQuery and posted via .ajax()
Well, I have a form that pops up in a modal dialog when a
I have a jquery-ui-dialog that contains a <form> which contains a <input type=file >
I have a form (with just one text area) that is submitted using AJAX
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have a Delphi 2006 app that pops up a modal alert dialog when
I have written a custom dialog (form) that I can use in a C#
I have a dialog form that can be opened as a modal or non-modal
I've got a situation where I have a main form that pops up an

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.