Skip to content

Commit 157b466

Browse files
committed
Merge pull request nkunihiko#14 from scardine/master
Delay the widget initialization
2 parents 433a9f5 + 042dd1d commit 157b466

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

bootstrap3_datetime/widgets.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,16 @@ def conv_datetime_format_js2py(cls, format):
8989

9090
js_template = '''
9191
<script>
92-
$(function() {
93-
$("#%(picker_id)s").datetimepicker(%(options)s);
94-
});
92+
(function(window) {
93+
var callback = function() {
94+
$(function(){$("#%(picker_id)s").datetimepicker(%(options)s);});
95+
};
96+
if(window.addEventListener)
97+
window.addEventListener("load", callback, false);
98+
else if (window.attachEvent)
99+
window.attachEvent("onload", callback);
100+
else window.onload = callback;
101+
})(window);
95102
</script>'''
96103

97104
def __init__(self, attrs=None, format=None, options=None, div_attrs=None, icon_attrs=None):

0 commit comments

Comments
 (0)