Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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

var tempoList = '.tempoStaticList';
var mainList = 'popup_Main_';
var subListOne = 'popup_Sub1_';
var subListTwo = 'popup_Sub2_';
var selectedOptionForSubListOne = 'One';
var selectedOptionForSubListTwo = 'Two';

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

  • No labels