Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9494 closed bug (notabug)

inst.drawMonth & inst.drawYear can't set on beforeShow

Reported by: ZardoZAntony Owned by: ZardoZAntony
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:

Description

need fix.

fix example:

_showDatepicker {
...
inst.drawMonth = inst.drawYear = -1;  
beforeShow = $.datepicker._get(inst, "beforeShow");
..
}
 _setDateFromField{
...
  if (inst.drawMonth == -1)     
      inst.drawMonth = inst.selectedMonth = date.getMonth();
  else 
       inst.selectedMonth = inst.drawMonth;

  if (inst.drawYear == -1)     
      inst.drawYear = inst.selectedYear = date.getFullYear();
  else
      inst.selectedYear = date.getFullYear();

//inst.drawMonth = inst.selectedMonth = date.getMonth();
//inst.drawYear = inst.selectedYear = date.getFullYear();

}

Change History (8)

comment:1 Changed 6 years ago by tj.vantoll

Owner: set to ZardoZAntony
Status: newpending

Hi ZardoZAntony,

Thanks for taking the time to contribute to the jQuery UI project. Can you please provide a test case that shows the problem that you are experiencing? You can use this as a starting point - http://jsfiddle.net/tj_vantoll/tRdpr/.

comment:2 Changed 6 years ago by ZardoZAntony

Status: pendingnew

comment:3 Changed 6 years ago by Scott González

Status: newpending

What made you think you were allowed to set those?

comment:4 Changed 6 years ago by ZardoZAntony

Status: pendingnew

Why not? And how i can set first draw month some other way? I show 3 months. The current date is in the middle.

comment:5 in reply to:  4 Changed 6 years ago by tj.vantoll

Resolution: notabug
Status: newclosed

The documentation makes it seem like this should be possible, but beforeShow is a bizarre API so I'm not sure there's much we could do to clarify that it isn't. After the widget factory rewrite there will be an open event that can be used as a hook to set options.

Replying to ZardoZAntony:

Why not? And how i can set first draw month some other way? I show 3 months. The current date is in the middle.

This seems like a reasonable feature request. Feel free to open another ticket for that and we might make that possible as part of the rewrite. Here's a hack-tastic way of accomplishing it http://jsfiddle.net/tj_vantoll/wmm2n/.

comment:6 Changed 6 years ago by Scott González

I don't see what makes it seem like this should be possible. Properties directly on the instance are private, they're never mention anywhere in the docs. It sounds like you're looking for the showCurrentAtPos option.

comment:7 in reply to:  6 Changed 6 years ago by tj.vantoll

Replying to scott.gonzalez:

I don't see what makes it seem like this should be possible. Properties directly on the instance are private, they're never mention anywhere in the docs. It sounds like you're looking for the showCurrentAtPos option.

Since drawMonth and other properties are on the object passed to beforeShow I could see thinking that you could set any of them. Datepicker has enough options that it's hard to know what's internal and what isn't. I clearly forgot about showCurrentAtPos for instance :P

comment:8 Changed 6 years ago by Scott González

I forget that the instance is passed around in datepicker :-/ The rewrite can't come soon enough.

Note: See TracTickets for help on using tickets.