所以我有这两个函数,然后是另一个函数调用它们。似乎我在函数调用之间失去了作用域。
var determineInteractionType = function( interaction ){
var param = interaction.parameterSet.param;
param.forEach(function( parameter, index, array ){
if( parameter.name === "INTERACTION-TYPE" ){
return parameter.value;
}
});
return null;
};
var getInteraction = function( id ){
customInteractions.forEach( function(interaction, index, array){
if( interaction.id == id ){
alert( id );
return interaction;
}
});
return null;
};
这是调用函数的一段代码。错误是即使 getInteraction 返回一个值,它也显示确定Interaction 正在传递一个 null 参数。
var _convertStemFromEAS = function(stem) {
var reg = new RegExp('@\{PRESENTATION-HTML-INTERACTION\}="(.*?)"');
var result;
var count = 1;
while ((result = reg.exec(stem)) !== null) {
var Match = result[0];
var dropdownGuid = result[1];
//The Error seems to be right here
var interactionType = determineInteractionType( getInteraction( id ) );
if( interactionType === "shortTextInteraction" ){
var escaped = $('<div/>').text('<select id="' + NewTmpGuid() + '" data-choice-id="' + dropdownGuid + '" style="width:100px;" data-count="' + count + '" class="easSelection"><option>DD' + count + '</option></select>').html();
}else if( interactionType === "essayTextInteraction" ){
}
count += 1;
stem = stem.replace(Match, escaped);
}
return stem;
};