【问题标题】:$(..)DatePicker is not function Error in Console$(..)DatePicker is not function 控制台中的错误
【发布时间】:2013-12-20 12:40:48
【问题描述】:

this 是我的子 jsp,它将被替换到母版页中查看整个代码 `

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.angelcam.dao.UserMethod"%>
<%@page import="com.angelcam.domain.UserWS"%>



<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%
    System.out.println("view details page called *****  ");
    System.out.println("view details page called *****  ");
    int id = Integer.parseInt(request.getParameter("id"));

    List<UserWS> list = new UserMethod().getUser(id);

    UserWS userWS = list.get(0);
%>


<link rel="stylesheet"
            href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
        <script src="http://code.jquery.com/jquery-1.9.1.js">
</script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">
</script>

<!--<script type="text/javascript" src="js/jtabber.js">
</script>
<script type="text/javascript" src="js/angelcamapp.js">
</script>

-->
<!--<link href="css/style.css" rel="stylesheet" type="text/css" />

-->
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(function() {
    $j("#datepicker").datepicker();
});
</script>


<form name="updateuser" action="UpdateUser" method="post" onsubmit="">

    <input type="hidden" name="id" value="<%=request.getParameter("id")%>">

    <div id="table">
        <div id="row">
            <div id="col1">
                First Name
            </div>
            <div>
                <input type="text" name="firstname" id="firstname"
                    value="<%=userWS.getFirstname()%>" class="inputtext" />
            </div>
        </div>

        <div id="row">
            <div id="col1">
                Last Name
            </div>
            <div id="col2">
                <input type="text" name="lastname" id="lastname" class="inputtext"
                    value="<%=userWS.getLastname()%>" />
            </div>
        </div>

        <div id="row">
            <div id="col1">
                Email
            </div>
            <div id="col2">
                <input type="text" readonly name="email" id="email"
                    class="inputtext" value="<%=userWS.getEmail()%>" />
            </div>
        </div>

        <div id="row">
            <div id="col1">
                DOB
            </div>
            <div id="col2">

                <input type="text" id="datepicker" />

            </div>
        </div>

        <div id="row">
            <div id="col1">
                Gender
            </div>
            <div id="col2">
                <%
                    if (userWS.getGender().equalsIgnoreCase("Male")) {
                %>
                <input type="radio" name="radio" value="Male" id="Male"
                    checked="checked" />
                Male
                <input type="radio" name="radio" value="Female" id="Female" />
                Female
                <%
                    } else {
                %>
                <input type="radio" name="radio" value="Male" id="Male" />
                Male
                <input type="radio" name="radio" value="Female" id="Female"
                    checked="checked" />
                Female

                <%
                    }
                %>
            </div>
        </div>

        <div id="row">
            <div id="col1">
                Password
            </div>
            <div id="col2">
                <input type="text" name="password" id="password" class="inputtext"
                    value="<%=userWS.getPassword()%>" />
            </div>
        </div>

        <div id="row">
            <div id="col1">
                Confirm Password
            </div>
            <div id="col2">
                <input type="text" name="confirmpassword" id="confirmpassword"
                    class="inputtext" value="<%=userWS.getPassword()%>" />
            </div>
        </div>

        <div id="row">
            <div id="col1">
                Status
            </div>
            <div id="col2">
                <%
                    if (userWS.isActiveflag()) {
                %>
                <input type="checkbox" name="status" id="status" checked="checked" />

                <%
                    } else {
                %>
                <input type="checkbox" name="status" id="status" />
                <%
                    }
                %>
            </div>
        </div>

        <div id="row">
            <div id="col1">
                &nbsp;
            </div>
            <div id="col2">
                <input type="submit" id="button" value="Save" />
            </div>
        </div>

    </div>
</form>
`![enter image description here][2]Hello i am using one Java Script date picker and i am using Ajax too in that. means to Replace Div into Master page.

Here i am using one Java Script Calender Control into the Child Jsp means which is Replacing threw Ajax into the Master Page here my Code is.

    <html>
       <head>
        <link rel="stylesheet"
        href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.js">
       </script>
      <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">
      </script>

      <script>
    $(function() {
        $("#datepicker").datepicker();
    });
    </script>


      </head>

    <body>
    <div id="row">
                <div id="col1">
                    DOB
                </div>
                <div id="col2">

                    <input type="text" id="datepicker" />

                </div>
            </div>

    </body>

    </html>

我也尝试在母版页中这样做,但它给出了同样的错误。表示父页面和子页面存在问题。 可能存在冲突错误,因为我也在使用其他 JavaScript 库,所以我不知道真正的问题是什么。 因为我单独尝试过它并且工作正常。 请帮我解决这个问题。 提前感谢您的帮助。

【问题讨论】:

  • 如果您使用另一个 JavaScript 库(可能会干扰 jQuery),请尝试使用 jQuery(function ($) { 作为您的第一行。
  • 是的,我试过了,但现在我遇到了这么多错误。像这样时间戳:2013 年 12 月 4 日星期三 12:01:07 IST 警告:解析“过滤器”值时出错。声明被放弃。源文件:code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css 线路:1175
  • 正如我所说的,我遇到了很多错误。
  • 这不是错误 - 它明确表示“警告”。这只是说您的浏览器忽略了 filter 的特定 CSS 值,因为您的浏览器不知道/识别如何使用它......并且不相关。

标签: javascript jquery ajax jsp datepicker


【解决方案1】:

您是否尝试过使用 noConlict 选项? jQuery.noConflict Documentation

【讨论】:

  • 当然让我附上那个代码,这样你就可以有想法了。
【解决方案2】:

试试这个:

<script>
  var $j = jQuery.noConflict();
  $j(function() {
    $j( "#datepicker" ).datepicker();
  });
</script>   

【讨论】:

  • 它可以工作,但现在我遇到了 CSS 和 Jquery 的一堆错误.. :(
  • 我已经更新了我的错误屏幕截图,所以请查看并建议我进行更改。
  • 看起来问题已经解决了。 CSS 错误不能帮助你太多,但我很确定 CSS 社区将能够帮助你解决这个问题。只需发布一个关于此的单独问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-18
  • 1970-01-01
  • 2017-02-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多