Opened 11 years ago

Closed 10 years ago

Last modified 9 years ago

#4481 closed bug (wontfix)

beforeShowDay breaks dialog when element is inline

Reported by: dmfontz Owned by:
Priority: minor Milestone: 1.8
Component: ui.datepicker Version: 1.7.1
Keywords: beforeShowDay, inline Cc:
Blocked by: Blocking:

Description

Seems to be related to the time it takes the beforeShowDay to execute. Adding a time out is a workaround. I also changed the beforeShowDay function to just return true and it worked. However, when the function actually does some processing the dp will not render.

See example here: http://jsbin.com/owita/edit

See discussion here: http://groups.google.com/group/jquery-ui/t/533b660261d3458d

Change History (3)

comment:1 Changed 10 years ago by Jörn Zaefferer

Component: ui.dialogui.datepicker
Milestone: TBD1.7.2

comment:2 Changed 10 years ago by Jörn Zaefferer

Milestone: 1.7.21.8

comment:3 Changed 10 years ago by kbwood

Resolution: wontfix
Status: newclosed

The problem appears to be that the callback function cannot access the array of dates to exclude, probably because it is all declared within the $(function() {}) initialiser callback. If the array and callback function are moved outside of this it all works again:

$(function() {
  $("#datepickerthing").datepicker({ 
    beforeShowDay: nationalDays,
    altField: '#actualDate', 
    minDate:'-11M', 
    maxDate: '+2M'
  });
}); 

  var natDays = ["4/22/2009","4/23/2009","4/24/2009","4/25/2009","4/26/2009","5/27/2009","5/28/2009","6/26/2009","6/27/2009","6/28/2009","6/29/2009","6/30/2009"];
  function nationalDays(date) {
    var sDate = (date.getMonth()+1).toString() + "/" + date.getDate().toString() + "/" + date.getFullYear().toString();
    if ($.inArray(sDate, natDays) != -1) return [false,"","Not this day!"];
    else return [true, ""];
  }
Note: See TracTickets for help on using tickets.