javascript - Calendar view doesn't work in html5 sometimes -


i creating application in django , have next problem. have search forms in application, , in of them there fields of type 'datefield'. in addition, have implemented jquery function display calendar view when user clicks on date fields. code next:

<script>     $(function() {        $( ".vdatefield" ).datepicker({ dateformat: 'yy-mm-dd' }).val();     }); </script> 

the problem doesn't work always. in pages, calendar view displayed correctly, in few others not. have put correctly class 'vdatefield' datefield attributes in forms in django this:

 self.fields['date'].widget.attrs = {'class': 'vdatefield'} 

so, why doesn't work?

thank much!

try wrap code in $(document).ready e.g.

<script> $(document).ready(function(){      $(function() {        $( ".vdatefield" ).datepicker({ dateformat: 'yy-mm-dd' }).val();     }); }); </script> 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -