twitter bootstrap date picker not working

放肆的年华 提交于 2020-01-04 07:26:15

问题


I have been extensively searching for the answer but i cant seem to find one that works. I am using Django 1.4, with twitter boostrap 2.0.4 and i am trying to use date picker (eyecon) with no success. When i click on the input box no date box shows up.

<div id="due_date">
        <input type="text" value="02/16/12" data-date-format="mm/dd/yy" id="datepicker" >
</div>

At the end of my base.html i have (right before closing the body):

<script src="/site_media/js/jquery.script.js"></script>
<script src="/site_media/js/bootstrap-datepicker.js"></script>

Finally on me jquery.script.js i have:

$(document).ready(function(){ $('.datepicker').datepicker()});

回答1:


You have selected all elements who have the class "datepicker", while your input element definition does not have such a class but rather has datepicker as id attribute set.

Either select the id field $("#datepicker") or add a class ".datepicker" to your input field.




回答2:


Do this: $(document).ready(function(){ $('#datepicker').datepicker()});

As you have set id="datepicker"

'.' is used for class and '#' is used for id



来源:https://stackoverflow.com/questions/11752223/twitter-bootstrap-date-picker-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!