Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The solution is to not add more focus events if they've already been added:
date_popup.js
/**
* Attaches the calendar behavior to all required fields
*/
(function ($) {
Drupal.behaviors.date_popup = {
attach: function (context) {
for (var id in Drupal.settings.datePopup) {
- $('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) {
+ $('#:not(.date-popup-processed)'+ id).addClass('date-popup-processed').bind('focus', Drupal.settings.datePopup[id], function(e) {
<SNIP>
});
}
}
};
})(jQuery);
Comment | File | Size | Author |
---|---|---|---|
#5 | 1840370-date-popupfocus-5.patch | 498 bytes | Jorrit |
| |||
#1 | 1840370-date-popup_js-1.patch | 633 bytes | vijaycs85 |
Comments
Comment #1
vijaycs85Let's see if it breaks any...
Comment #4
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedI think it is more appropriate with respect to Drupal standards to make this change:
For AJAX requests context is set to the container where new contents are placed. Elements outside this container are automatically not affected.
Comment #5
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedPlease see the attached patch.
Comment #6
steinmb CreditAttribution: steinmb as a volunteer commentedThank you for the patch.
JS is not area of expertise so I just have to ask to be sure. Will this change break anything for existing sites changing this?
Comment #7
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedIt works for me ™
Comment #8
steinmb CreditAttribution: steinmb as a volunteer commentedHave to leave it some one else to RTBC it then.