javascript - bootstrap-datepicker set language globally -
i'm using bootstrap-datepaginator within uses bootstrap-datepicker. utilizzanto bootstrap-datepicker single component, there no problems set language, same not true using bootstrap-datepaginator. how can do?
i'm trying set italian language default entire project. in index.html
set next script:
<script src="vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"></script> <script src="vendors/jquery-ui/ui/i18n/datepicker-it.js"></script> <script> $(function() { $( "#datepicker" ).datepicker( $.datepicker.regional[ "it" ] ); }); </script>
but in console these errors:
uncaught typeerror: cannot read property 'regional' of undefined datepicker-it.js:15 uncaught typeerror: cannot read property 'regional' of undefined (index):394
i tried i'm going crazy!
bootstrap datepicker i18n
i changed code in way:
<script src="vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"></script> <script src="vendors/bootstrap-datepicker/js/locales/bootstrap-datepicker.it.js"></script> <script> $(function() { $.datepicker.setdefaults( $.datepicker.regional["it"] ); }); </script>
but error follows:
uncaught typeerror: cannot read property 'setdefaults' of undefined
with fix:
$('.datepicker').datepicker({ language: "it" });
i haven't got errors in console language english language default
you can set default options bootstrap datepicker assigning them so:
$.fn.datepicker.defaults.language = 'it';
example below:
class="snippet-code-js lang-js prettyprint-override">$(document).ready(function(){ $.fn.datepicker.defaults.language = 'it'; }); $(document).ready(function(){ $('.datepicker').datepicker(); });
class="snippet-code-html lang-html prettyprint-override"><link href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script> <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/locales/bootstrap-datepicker.it.js"></script> <input class="datepicker"/>
javascript angularjs datepicker bootstrap-datepicker bootstrap-datetimepicker
No comments:
Post a Comment