遵循简单的“完整”示例,在阅读了Wiki并在moxie论坛上搜索答案后,到目前为止我什么都没有想出来。基本上,我正在尝试执行what the wiki suggests is possible,但当我用匿名函数补充示例的'staffid‘值时,该变量没有被替换。
template_replace_values : {
username : "Jack Black",
staffid : function(e){
var staffidInput = yd.get('staffidInput');
return (staffidInput !== null)? staffidInput.value : '0178678';
}
}...but它不工作,所以我在实例化tinyMCE之前定义了这个函数:
function getStaffId(){
var staffidInput = yd.get('staffidInput');
alert('template_replace_values processed, staffidInput: '+staffidInput);
return (staffidInput !== null)? staffidInput.value : '555555';
}
... more instantiation code...
template_replace_values : {
username : "Jack Black",
staffid : getStaffId()
}...and值只在第一次被提取,它从来不会像维基建议的那样更新(每当执行“清理”过程时)。我猜某个地方有什么东西是未定义的,不会抛出错误,因为我第二次成功的尝试中的'getStaffId‘在tinyMCE iframe文档上下文中是未定义的,我想是吗?
我的目标是让变量可以在模板预览屏幕中配置,也可以在插入模板后配置。
发布于 2010-11-22 07:23:01
而不是这样:
template_replace_values : {
username : "Jack Black",
staffid : getStaffId()
}这一点:
template_replace_values : {
username : "Jack Black",
staffid : getStaffId
}getStaffId()执行该函数并使用其返回值作为staffid的值,getStaffId使用该函数作为staffid的值。
https://stackoverflow.com/questions/4220658
复制相似问题