Reputation: 3369
I am creating a JIRA custom field plugin and want to use below 'datetime picker' control as a 'monthyear picker' given in below link. http://jquerybyexample.blogspot.com/2012/06/show-only-month-and-year-in-jquery-ui.html
JIRA version is '5.2.11'
JQUERY control STUFF in velocity template:
<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 error says as below:
"TypeError: Object [object Object] has no method 'datepicker' [
http://localhost:2990/jira/s/en_US1rk3us/787/3/1/_/download/superbatch/js/batch.js:9919
"
any idea, how i could use this control in to custom field - velocity template and gets working ?
Upvotes: 0
Views: 1326
Reputation: 17846
Try to edit the file system-webresources-plugin.xml
(should be at /atlassian-jira/WEB-INF/classes/), and add to <web-resource key="jira-fields">
this code:
<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>
Don't use AJS.$
- this is Jira's internal jQuery. Using this will prevent jQuery ui from working. Try using jQuery directly:
$(document).ready(function () {
$('#txtDate').datepicker({
.....
and so on..
Upvotes: 0