Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#9105 closed bug (notabug)

Datepicker should not rely on unique element id

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

Description

The datepicker currently does not work correctly if applied to an element with a non-unique id.

The picker will open as intended, but when date is clicked it may end up in the wrong input element. In some cases nothing at all will happen, expect for console error "s is undefined" ("inst is undefined") when non-minified.

A simple web search for "datepicker non-unique id" will reveal that this is a common problem. It is hard to debug this scenario since non-unique element id does not in itself cause a visible error message, and the message generated from the datepicker is not helpful to discover the true problem.

The datepicker control should be changed so that it does not fail in the presence of non-unique element ids.

If the consensus is that the datepicker should insist on having a unique element id, then it should at least be changed to emit a clear console error, either when being added or when being opened. This would improve developer usability, given that it's now a hard problem to debug.

Change History (5)

comment:1 Changed 7 years ago by Scott González

Resolution: notabug
Status: newclosed

It's invalid to ever have duplicate IDs in a document.

comment:2 Changed 7 years ago by obbe

And yet duplicate ids happens very easily and is hard to debug. Please share your thoughts on the possibility of a warning message to improve on developer usability.

Is the current behavior consistent with the goals of "and a bit of common sense to create a robust and flexible set of UI widgets" and "intuitive API", as described at: http://wiki.jqueryui.com/w/page/12138130/Vision%20and%20Goals

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

And yet duplicate ids happens very easily and is hard to debug. Please share your thoughts on the possibility of a warning message to improve on developer usability.

It doesn't matter how common it is. It's invalid. If you want something to yell at you about your code, use a validator. Validating your HTML is not jQuery or jQuery UI's responsibility.

Is the current behavior consistent with the goals of "and a bit of common sense to create a robust and flexible set of UI widgets" and "intuitive API", as described at: http://wiki.jqueryui.com/w/page/12138130/Vision%20and%20Goals

Absolutely. Robust does not mean works with invalid input.

comment:4 Changed 7 years ago by Scott González

#9253 is a duplicate of this ticket.

comment:5 in reply to:  1 Changed 7 years ago by ronak128

Replying to scott.gonzalez:

It's invalid to ever have duplicate IDs in a document.

But how does it affect the datepicker??

Note: See TracTickets for help on using tickets.