2012-08-09 58 views
1

我发布了这个在fogbugz板上,但我希望有一个更快的反应。动态更改的下拉列表不会令人耳目一新。 (Fogbugz)

下面的脚本完成我想要的操作,除非需要更改ixproject字段(可能是因为我的其他项目不使用子类别),以便使用新值更新下拉列表。有没有办法刷新某些HTML元素后,其值已被更改。

$(document).ready(function(){ 
    var categoryChanged = $('#ixCategory'); 
    var reloadProject = $('#ixProject'); 
    // We don't need Schedule Item so remove it. From our options. 
    var removeScheduleItem = document.getElementById("ixCategory"); 
    var select = document.getElementById("subcategorya85"); 

    //Remove all options that may exist. 
    function resetSelectBox(){ 
     var select = document.getElementById("subcategorya85"); 
     select.options.length = 0; 
    } 

    //Remove all options before starting. 
    $(document).ready(function() { 
     resetSelectBox(); 
     select.options[0] = new Option("--"); 
     //removes schedule item from ixcategory 
     removeScheduleItem.remove(3); 
    }); 
    categoryChanged.on("change", function(event){ 
    if (($('#ixCategory')[0].selectedIndex == 0)) 
    { 
     resetSelectBox(); 
     select.options[0] = new Option("A", "A"); 
     select.options[1] = new Option("B", "B"); 
     select.options[2] = new Option("C", "C"); 
    } 
    else 
    if (($('#ixCategory')[0].selectedIndex == 1)) 
    { 
     resetSelectBox(); 
     select.options[0] = new Option("D", "D"); 
     select.options[1] = new Option("E", "E"); 
    }else 
    if (($('#ixCategory')[0].selectedIndex == 2)) 
    { 
     resetSelectBox(); 
     select.options[0] = new Option("F", "F"); 
    }else 
    if (($('#ixCategory')[0].selectedIndex == 3)) 
    { 
     resetSelectBox(); 
     select.options[0] = new Option("G", "G"); 
    } 
    }) 
}); 

编辑:我将完全相同的脚本复制到小提琴并得到所需的结果。 http://jsfiddle.net/themaniac27/VNfFH/

我需要做什么不同才能让它在Fogbugz中工作。这是尝试使用fogbugz按需试用。

+0

你有什么问题?这不是很明确 – Undefined 2012-08-09 14:01:03

+2

为什么你在$(document).ready中有$(document).ready? – jperelli 2012-08-09 14:04:21

+0

@Sam当我在Fogbugz中运行脚本时,select元素不会更新。在用户更改用户类别之前,旧选项值仍可选。 – themaniac27 2012-08-09 14:13:24

回答

0

看起来像the fogbugz boards gave me an answer

FogBugz的” droplists纷纷加入到 他们的各种附加功能,让他们可以是一个有点棘手直接修改。基本上, 您需要调用DropListControl.refresh()并传入底层的 DOM元素。另一件需要考虑的事情是,FogBugz可以从查看案件转为编辑案件。

相关问题