春天,jQuery中基于表单标签的Datepicker? [英] Spring, Form tag based Datepicker in Jquery?

查看:62
本文介绍了春天,jQuery中基于表单标签的Datepicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,在我的Spring应用程序中,我在jsp代码中使用了基于spring的form标记.

Actually in my Spring application i'm using spring based form tag in my jsp code.

并为此<form:input>添加功能,使用Jquery提供DatePicker.

And add the functionality for this <form:input>,provide DatePicker using Jquery.

这是我的Jsp代码.

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<link rel="stylesheet" href="resources/css/jquery-ui.css" type="text/css">
<link rel="stylesheet" href="resources/css/custom.css" type="text/css">
<script type="text/javascript" src="resources/jquery/jquery-ui.min.js"></script>
    <form:form action="form/form1"
        modelAttribute="form1">
               <label class="control_label_c">From : </label>
          <div class="controls_c">
              <form:input type="text" path="fromDate" class="date-picker" />
        </div>
    </form:form>
<script>
$(function() {
    $('.date-picker').datepicker( {
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'MM yy',
        onClose: function(dateText, inst) { 
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
        }
    });
});
</script>

但是日期选择器不起作用(不可见)...

But date picker not working (not visible)...

这个基于spring的表单标签有什么问题吗?或

Is there any problem in this spring based form tag? or

我的代码有什么问题吗?

Is there anything wrong in my code?

推荐答案

主要是因为引用问题.请检查以下内容,最好使用浏览器中的Firebug或开发人员工具

It's mostly because reference issues. Please check following, preferably using Firebug or developer tools in browser

  1. 正确引用了具有兼容版本jQuery的jQuery UI
  2. 正确引用了jQuery UI CSS
  3. 引用了jQuery UI js

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/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.2/jquery-ui.js"></script>

这篇关于春天,jQuery中基于表单标签的Datepicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆