0

好吧,好吧,这一定是一件非常愚蠢的事情。

我有一个小的 JSP 应用程序。我想添加一个日期选择器。我下载了 jQuery UI 包。如果我将 chrome 指向它作为演示提供给我的 index.html,那么一切都很好。当我将这些碎片移到我的 web 应用程序中时,效果不太好。

chrome 控制台显示了两件事:

  1. 资源解释为脚本,但使用 MIME 类型 text/html 传输。
  2. 未捕获的类型错误:对象 # 没有方法 'datepicker'

显然,第二个是头痛的地方。我确实有一个 <div id='日历'>。

<head>
        <link rel="stylesheet" type="text/css" href="/css/harvest.css" />
        <link type="text/css" href="/css/smoothness/jquery-ui-1.8.2.custom.css" rel="stylesheet" />
        <title>Data Collection</title>
        <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="/js/jquery-ui-1.8.custom.min.js"></script>
        <script type="text/javascript"> 
            $(function(){
                // Datepicker
                $('#calendar').datepicker({
                    inline: true, altField: 'input#date', altFormat: 'yy-mm-dd'
                });
            });
        </script>
    </head>
4

2 回答 2

1

EDIT: I figured it out. (I'm pretty certain)

you have a script loading from /js/jquery-ui-1.8.custom.min.js, but when I dl a ui bundle, it downloads a file js/jquery-ui-1.8.2.custom.min.js. Notice that the second one has a 2 in it. When I did that, everything worked again for me.

Here are the following basics that I can think of:

  • what happens when you directly go to /js/jquery-1.4.2.min.js and /js/jquery-ui-1.8.custum.min.js ? If those don't work then obviously you have a wrong pathname.
  • have you downloaded a jquery ui package before? perhaps the index.html page you are viewing is not associated with the ui package you dl'ed but with a differently downloaded ui package (which may indicate that you simply forgot to check the datepicker box when dl'ing it this latest time)
  • is there some page that's cached in Chrome? does deleteing all cache help?
  • what happens when you try it in FF, IE, or Safari?
于 2010-07-03T23:25:36.297 回答
0

出现此错误的另一个原因是当您使用如下错误的情况进行调用时: $("#calendar").date* P *icker() 而不是 $("#calendar").datepicker()

几个小时以来,我一直在努力寻找这个错误。

于 2010-11-06T20:40:52.267 回答