asaglimbeni / django-datetime-widget

Bootstrap django-datetime-widget is a simple and clean widget for DateField, Timefiled and DateTimeField in Django framework. It is based on Bootstrap datetime picker, supports both Bootstrap 3 and Bootstrap 2
Other
219 stars 125 forks source link

attempt to fix #61 #72

Open siolag161 opened 9 years ago

siolag161 commented 9 years ago

As suggested by the title, this is a simple fix for #61 :

       <script type="text/javascript">
         document.addEventListener("DOMContentLoaded", function(event) {
           $("#%(id)s").datetimepicker(%(options)s);
          });
       </script>

Please note that it does not work in IE8 or older ( due to the lack of support for DOMContentLoaded). Look at here for a discussion on how to do onDocumentReady without Jquery loaded. (I'm not a fan of defer)

rafaelverger commented 8 years ago

@siolag161 why you did not use $(wrapper) instead of document.addEventListener('DOMContentLoaded') ?

<script type="text/javascript">
  $(function() {
    $("#%(id)s").datetimepicker(%(options)s);
  });
</script>
rafaelverger commented 8 years ago

BTW +1 for this :clap:

bardo commented 8 years ago

@rafaelverger He doesn't use jQuery because that's the whole issue of #61: if jQuery is loaded at the bottom of the page the code will fail.