#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)
Change History (4)
Changed 14 years ago by
Attachment: | ui.datepicker.js added |
---|
comment:1 Changed 14 years ago by
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 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Multiple elements can't have the same id. This is invalid HTML and is therefore unsupported.
source with the code changed to manage the target element via class instead than via ID