WCF.Date.Picker now supports dynamic content
authorAlexander Ebert <ebert@woltlab.com>
Mon, 17 Dec 2012 15:40:09 +0000 (16:40 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 17 Dec 2012 15:40:09 +0000 (16:40 +0100)
Fixes #981

wcfsetup/install/files/js/WCF.js

index f6db066a52cc76935591c114f99b51ed494b87c0..8afbca55639f664c55bed76af4249480e81de4ec 100755 (executable)
@@ -2032,9 +2032,18 @@ WCF.Date.Picker = {
         * Initializes the jQuery UI based date picker.
         */
        init: function() {
-               $('input[type=date]').each(function(index, input) {
+               this._initDatePicker();
+               
+               WCF.DOMNodeInsertedHandler.addCallback('WCF.Date.Picker', $.proxy(this._initDatePicker, this));
+       },
+       
+       /**
+        * Initializes the date picker for valid fields.
+        */
+       _initDatePicker: function() {
+               $('input[type=date]:not(.jsDatePicker)').each(function(index, input) {
                        // do *not* use .attr()
-                       var $input = $(input).prop('type', 'text');
+                       var $input = $(input).prop('type', 'text').addClass('jsDatePicker');
                        
                        // TODO: we should support all these braindead date formats, at least within output
                        $input.datepicker({