Reputation: 3008
I made this topic here, but wasn't sure how to reply to it and still get an answer to my NEW question... so I just made this topic.
Ok so I have my datepicker adding a class above/below on beforeShow, but now I need it to change one of its OPTIONS on beforeShow as well (so that it animates as slideUp or slideDown depending on if its opening above or below).
inst.settings.showAnim = 'slideUp';
sets the options in the DOM tab on firebug under DP_jQuery_1308014346347.datepicker._curInst.settings.showAnim
but then it won't show the datepicker.
Actually, I just noticed setting showAnim: 'slideUp' wont even work by itself, does that mean the datepicker won't accept it o_O? Seems a bit weird...
Can anyone help please :)?
Upvotes: 1
Views: 8701
Reputation: 3008
Solution:
Don't change the settings in the instance, change it from calling the plugin again.
beforeShow: function(input, inst) {
if (inst.dpDiv.position().top > $(input).position().top) {
$(inst.dpDiv).removeClass('ui-datepicker-above').addClass('ui-datepicker-below');
$(input).removeClass('above').addClass('below');
$('#order-main .datepicker').datepicker('option','showAnim','slideDown');
} else {
$(input).removeClass('below').addClass('above');
$(inst.dpDiv).removeClass('ui-datepicker-below').addClass('ui-datepicker-above');
$('#order-main .datepicker').datepicker('option','showAnim','fadeIn');
}
Upvotes: 0
Reputation: 2061
Where exactly are you trying to set the animation option?
If you are initializing a datepicker with the animation option you write:
$("#myDatePicker").datepicker({
showAnim: 'slideUp'
});
If the datepicker has already been initialized then you have to use the second method:
$("#myDatePicker").datepicker("option", "showAnim", "slideUp");
Upvotes: 2