Skip to content
This repository was archived by the owner on Jul 11, 2019. It is now read-only.

Commit b0b656a

Browse files
committed
DateTimePicker for dynamically created controls.
DateTimePicker will be now aware of dynamically created controls (for example if form is loaded as some kind of modal mode, not in tab).
1 parent 2fa9ea5 commit b0b656a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

bootstrap3_datetime/widgets.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,22 @@ def conv_datetime_format_js2py(cls, format):
9393
var callback = function() {
9494
$(function(){$("#%(picker_id)s:has(input:not([readonly],[disabled]))").datetimepicker(%(options)s);});
9595
};
96-
if(window.addEventListener)
96+
// if window object id loaded already, call directly callback function
97+
if (-1 != $.inArray(
98+
document.readyState,
99+
["loaded", "interactive", "complete"]
100+
)
101+
) {
102+
callback();
103+
}
104+
else if (window.addEventListener) {
97105
window.addEventListener("load", callback, false);
98-
else if (window.attachEvent)
106+
}
107+
else if (window.attachEvent) {
99108
window.attachEvent("onload", callback);
100-
else window.onload = callback;
109+
}
110+
else
111+
window.onload = callback;
101112
})(window);
102113
</script>'''
103114

0 commit comments

Comments
 (0)