在Bugzilla中获得访问bug_status.name的问题

时间:2010-07-15 11:31:39

标签: bugzilla

我正在使用JavaScript根据从下拉菜单中选择的错误状态,将特定的默认文本动态输出到Bugzilla中的其他注释框。我尝试过使用'bug.bug_status',但这只会在页面提交时发生变化。我找到的填充下拉菜单的变量是'bug_status.name'但是当我尝试使用这个变量时,似乎没有被识别出来。有没有人提出任何可能导致问题的建议?有人曾尝试过这个吗?

以下代码放在knob.html.tmpl文件的开头。

[% PROCESS global/variables.none.tmpl %]
[% # Output a specific default content in the comments box depending on bug status. %]
<script type="text/javascript">
<!--
var messages = ['Message 0', 'Message 1', 'Message 2', 'Message 3', 'Message 4',    'Message 5', 'Message 6'];
function changetext(selectObj){
   var textAreaElement = document.getElementsByName("comment")[0];
[% IF (bug_status.name == "ASSIGNED") %]
   textAreaElement.value = messages[4];
[% ELSIF(bug_status.name == "RESOLVED") %]
   textAreaElement.value = messages[5];
[% ELSE %]
   var variable1 = 0;
   variable1 = bug_status.name
   textAreaElement.value = variable1;
[% END %]

1 个答案:

答案 0 :(得分:0)

基于your other question,您似乎希望在用户选择新状态时在客户端进行更改。但是,您在此问题中编写的代码将在客户端看到之前在服务器端更改。你的if / else树需要用javascript而不是Template Toolkit编写。

所以,像这样:

function changetext(selectObj){
  var textAreaElement = document.getElementsByName("comment")[0];
  var currentStatus = document.getElementById("bug_status").value;

  if (currentStatus == "ASSIGNED") {
    textAreaElement.value = messages[4];
  } else if (currentStatus == "RESOLVED") {
    textAreaElement.value = messages[5];
  } else {
    textAreaElement.value = currentStatus;
  }
}