Unable to change jQuery Datepicker properties

The application in which I work has a common date format setting. All pages inherit the following javascript in the header:

$(document).ready(function () {
   $(':input[data-datepicker]').datepicker({ dateFormat: 'mm-dd-yyyy' });
});

Now I have a page where I need to add my own properties in Datepicker, for example, get the MaxDate property setting:

Reference:
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.18.min.js")" type="text/javascript">\</script>
.
.
.
// Setting Datepicker properties. 
// ( I want today date to be the max date a user can pick: )

$(function () {
   $('#addDate').datepicker({ maxDate: 0 });
});
.
.
.

Highlighted HTML:

<input data-datepicker="True" id="addDate" name="Date" type="text" value="" />

Currently, no additional properties that I am adding to $ ('# addDate') are being added. datepicker like MaxDate or defaultDate seems to take effect. Help!

+3
source share
2 answers

Odd, but I decided. He did this when, instead of using options, I overwrite it with a function:

$('#addDate').datepicker("option", "maxDate", '+0D');
+1
source

$('# addDate'). datepicker ({maxDate: 0});

$('# addPriorityDate'). datepicker ({maxDate: 0});

0

All Articles