jquery UI datepicker is missing style/css

混江龙づ霸主 提交于 2019-12-25 01:55:35

问题


I just googled this datepicker for use in angular. The problem is that the style/css is missing:

myApp.directive('calendar', function () {
            return {
                require: 'ngModel',
                link: function (scope, el, attr, ngModel) {
                    $(el).datepicker({
                        dateFormat: 'yy-mm-dd',
                        onSelect: function (dateText) {
                            scope.$apply(function () {
                                ngModel.$setViewValue(dateText);
                            });
                        }
                    });
                }
            };
        })

Does anyone know how to fix the style? Looks like jquery ui css or something? jsfiddle: http://jsfiddle.net/dingen2010/a6WDH/1/


回答1:


Check this JsFiddle you just needed to add Ui.css In external recourse tab on lef of jsFiddle u had to add external css of Ui

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>

<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">

<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>



回答2:


add a reference to jquery-ui.css in your page



来源:https://stackoverflow.com/questions/22111132/jquery-ui-datepicker-is-missing-style-css

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