有一次,根据切换开关的状态,我需要一个菜单,你可以有多个选项或一个选项。这些菜单位于Jquery Tabs中。如果我创建一个新选项卡,则会正确填充菜单。如果我尝试在现有选项卡中交换菜单,那么它就不能正常工作。首先,右边没有复选框(或者它不应该没有复选框),菜单在我点击之前不会更新。
这是每次翻转切换开关时调用的代码。
function setPicker(){
var currentTab = globalCurrentTab;
var exchange = currentTab.attr("exchange");
var symbol = currentTab.attr("symbol");
if($("#flip-min option:selected").html() == "Graph") { //no multiple attribute
$('#select-choice-'+symbol+'-'+exchange).empty();
$('#select-choice-'+symbol+'-'+exchange).removeAttr('multiple');
$('#select-choice-'+symbol+'-'+exchange).append('<option>Choose Fields</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=1>My option1</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=2>My option2</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=3>My option3</option>');
}
else { //yes multiple attribute
$('#select-choice-'+symbol+'-'+exchange).find('option').remove().end();
$('#select-choice-'+symbol+'-'+exchange).attr('multiple','multiple');
$('#select-choice-'+symbol+'-'+exchange).append('<option>Choose Fields</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=1>My option1</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=2>My option2</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=3>My option3</option>');
$('#select-choice-'+symbol+'-'+exchange).append('<option value=4>My option4</option>');
}
}