无法在速度模板(JIRA自定义字段插件)中使用jquery控件日期时间选择器



我正在创建一个JIRA自定义字段插件,并希望使用下面的"日期时间选择器"控件作为下面链接中给出的"月份选择器"。http://jquerybyexample.blogspot.com/2012/06/show-only-month-and-year-in-jquery-ui.html

JIRA版本为"5.2.11"

JQUERY控制速度模板中的STUFF:

<script type="text/javascript">
    alert("Handler for .click() called.");  //get alert
    AJS.$("#target").click(function() {      //get alert while click on below "target" div.
        alert("Handler for .click() called.");
    });
    AJS.$(document).ready(function () {       
        AJS.$('#txtDate').datepicker({     //shows javascript error as"[object Object] has no    method 'datepicker' "              
            changeMonth: true,
            changeYear: true,
            dateFormat: 'MM yy',
            onClose: function () {
                var iMonth = AJS.$("#ui-datepicker-div .ui-datepicker-month :selected").val();
                var iYear = AJS.$("#ui-datepicker-div .ui-datepicker-year :selected").val();
                AJS.$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
            },
            beforeShow: function () {
                if ((selDate = AJS.$(this).val()).length > 0) {
                    iYear = selDate.substring(selDate.length - 4, selDate.length);
                    iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5), AJS.$(this).datepicker('option', 'monthNames'));
                    AJS.$(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 1));
                    AJS.$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
                }
            }
        }); 
    });
    alert('final');  // not alert as error at above code
</script> 

javascript错误显示如下:

"TypeError:Object[Object Object]没有方法'datepicker'[http://localhost:2990/jira/s/en_US1rk3us/787/3/1/_/download/superbatch/js/batch.js:9919"

有什么想法吗,我如何使用这个控件来自定义字段速度模板并开始工作?

尝试编辑文件system-webresources-plugin.xml(应位于/atlassian jira/WEB-INF/classes/),并将以下代码添加到<web-resource key="jira-fields">中:

<resource type="download" name="jquery.min.js" location="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
    <param name="source" value="webContextStatic"/>
</resource>
<resource type="download" name="jquery-ui.min.js" location="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js">
    <param name="source" value="webContextStatic"/>
</resource>

不要使用AJS.$——这是Jira的内部jQuery。使用它将阻止jQueryui工作。尝试直接使用jQuery:

$(document).ready(function () {       
     $('#txtDate').datepicker({
          .....

等等。

最新更新