twitter bootstrap - Datepicker calendar doesn't display in modal -
i new coding , having trouble getting bootstrap-datepicker (https://github.com/nerian/bootstrap-datepicker-rails) open correctly. while modal works, datepicker not - i'd appreciate if point me in right direction.
i'm not sure whether problem caused by:
a) javascript in wrong place? have couple of <script>
under <head>
, datepicker script right before </body>
tag.
b) missing file in assets/javascripts? i've added bootstrap.js , bootstrap-datepicker.js here already.
c) else?
here's html in application.html.erb
:
<head> <%= stylesheet_link_tag "application", media: "all" %> <%= javascript_include_tag "application" %> <script src="http://code.jquery.com/jquery.js"></script> <script src="assets/javascripts/bootstrap.js"></script> <%= csrf_meta_tags %> <%= render 'layouts/shim' %> </head> <body> <div id="container"> <a id="link" href="#mymodal" class="btn btn-large btn-primary" data-toggle="modal">get started now</a> <div class="modal hide fade" id="mymodal" aria-hidden="true"> <div class="well"> <input type="text" data-behaviour='datepicker' > </div> </div> </div> <script type="text/javascript"> $(document).ready(function() { $('[data-behaviour~=datepicker]').datepicker({ "format": "yyyy-mm-dd", "weekstart": 1, "autoclose": true }) }); </script>
thanks help!
solved own problem. issue was loading javascript files many times:
a) installing gems , using //= require
in application.js
file
b) placing files in assets/javascripts folder (these files loaded second time through //= require_tree .
in application.js
file)
c) linking files through <script>
tags in html
fixed issue doing a) only. hope helps else!
Comments
Post a Comment