Opened 11 years ago

Closed 11 years ago

Last modified 7 years ago

#3460 closed enhancement (notabug)

conflict if multiple input with same ID exists. Changed the code to use classes.

Reported by: g_gus Owned by: grabanski
Priority: minor Milestone:
Component: ui.datepicker Version:
Keywords: multiple id classes Cc:
Blocked by: Blocking:

Description

I have a code I can't modify, and unfortunately there are some input boxes with same ID.

In this case, the datepicker only updates the first one. (in this case I have some datepickers inside a lightbox. I can't really know if the IDs of the page that contains the lightbox won't conflict..)

I changed the code to work on classes instead than on IDs. I'm posting my code here so in case you can have a look at it.

Attachments (1)

ui.datepicker.js (71.9 KB) - added by g_gus 11 years ago.
source with the code changed to manage the target element via class instead than via ID

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by g_gus

Attachment: ui.datepicker.js added

source with the code changed to manage the target element via class instead than via ID

comment:1 in reply to:  description Changed 11 years ago by g_gus

Basically the code changes are theese:

First, store the information about the target into a Class (creating always a new string via uuid

dp_class = 'dp' + ++this.uuid; 
$(target).addClass(dp_class);
$(target).attr('dp_class',dp_class);

then in _newInst just return a class instead than a id:

return {class: target.attr('dp_class'), ...

and then the code changes all the queryes from #init.id to .init.class

that's it.

comment:2 Changed 11 years ago by Scott González

Resolution: invalid
Status: newclosed

Multiple elements can't have the same id. This is invalid HTML and is therefore unsupported.

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

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.