This script will enable you to reproduce the behaviour of dependent dynamic dropdowns as were known in Tempo 8.1 and earlier.
Given three static lists in the Tempo Worklog Attributes:
- Main (required)
- Sub1 (optional)
- Sub2 (optional)
The Sub1 list will only be displayed when the value 'One' is selected in the Main list, Sub2 list only when the value is 'Two'.
Script
// Enter your fieldnames here:
var mainListName = 'Main';
var subListOneName = 'Sub1';
var subListTwoName = 'Sub2';
var selectedOptionForSubListOne = 'One';
var selectedOptionForSubListTwo = 'Two';
// Don't change the code below this line
var tempoList = '.tempoStaticList';
var mainList = 'popup_' + mainListName + '_';
var subListOne = 'popup_' + subListOneName + '_';
var subListTwo = 'popup_' + subListTwoName + '_';
AJS.$(document).ready(function() {
AJS.$('#time-popup').live('focus', function() {
AJS.$('.tempoStaticList').each( function(index, item) {
if (AJS.$(item).attr('id') != mainList) {
AJS.$(this).parent().hide();
}
});
AJS.$(tempoList + '[id$="' + mainList + '"').live('change', function() {
if (AJS.$(this).val() == selectedOptionForSubListOne) {
AJS.$('.tempoStaticList').each( function(index, item) {
if (AJS.$(item).attr('id') == mainList || AJS.$(item).attr('id') == subListOne) {
AJS.$(item).parent().show();
} else {
AJS.$(item).parent().hide();
}
});
} else if (AJS.$(this).val() == selectedOptionForSubListTwo) {
AJS.$('.tempoStaticList').each( function(index, item) {
if (AJS.$(item).attr('id') == mainList || AJS.$(item).attr('id') == subListTwo) {
AJS.$(item).parent().show();
} else {
AJS.$(item).parent().hide();
}
});
} else {
AJS.$('.tempoStaticList').each( function(index, item) {
if (AJS.$(item).attr('id') == mainList) {
AJS.$(item).parent().show();
} else {
AJS.$(item).parent().hide();
}
});
}
});
});
});
Demo