Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
30
rated 0 times [  33] [ 3]  / answers: 1 / hits: 105336  / 11 Years ago, wed, january 8, 2014, 12:00:00

I am developing a asp.net MVC4 project where i use lots of JqueryUI datepicker.



For one of my date picker when i tried to click on datepicker image i am getting some error like,



Uncaught TypeError: Cannot read property 'settings' of undefined                jquery-ui-1.10.3.min.js:9


Html



<div>
<input type=text id=tsDte style=font-size: 14px;width: 50% >
<img src=~/Images/dayPicker.png onclick=tsDatePickerClick() style=vertical-align:bottom/>
</div>


Javascript



var currentDate = new Date();

$(#tsDte).datepicker({
dateFormat: 'yy-mm-dd',
maxDate: 0,
changeYear: true
}).attr('readonly', 'readonly');
$(#tsDte).datepicker(setDate, currentDate);


function tsDatePickerClick() {
$(#tsDte).datepicker('show');
}


Here i have a Textfield and a datepicker image.When i click on datepicker image datepicker will popup .



i have followed the similar way in other datepicker and they are working fine.I have only problem with this date picker.



Any help is appreciated.


More From » jquery

 Answers
41

I think your datepicker wasn't created correctly, so when you call show, it expects a settings object.



Probably you didn't create it inside $(document).ready, you should have:



$(document).ready(function(){      //Add this line (and it's closing line)
var currentDate = new Date();

$(#tsDte).datepicker({
dateFormat: 'yy-mm-dd',
maxDate: 0,
changeYear: true
}).attr('readonly', 'readonly');
$(#tsDte).datepicker(setDate, currentDate);
});


Hope this helps. Cheers


[#73319] Monday, January 6, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antonb

Total Points: 424
Total Questions: 104
Total Answers: 101

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;