我有两个功能。我想要这个功能:
function indentSpace(s, n){
return ((new Array(n+1)).join(s));
}
要从此功能获取它的参数,同时允许此功能继续:
function onHandle(line, report) {
var input = $.trim(line);
if (parensBalanced(input) == false) {
indentSpace('.',input.length);
controller.continuedPrompt = true;
} else if (parensBalanced(input) == true) {
controller.continuedPrompt = false;
if (doCommand(input)) {
report();
return;
}
...
}
}
这里使用第一个函数,作为continuedPromptLabel
的值:
$(document).ready(function() {
controller = $("#console").console({
continuedPromptLabel: indentSpace,
completeHandle: onComplete,
});
});
我已经尝试了几种不同的方式,似乎一旦我得到indentSpace
的值,它也会在其包含的函数中返回该值 - 并打破其他东西。
干杯!
答案 0 :(得分:0)
所以你希望indentspace从onHandle异步调用它的参数上有一个闭包,这样onHandle可以自由运行,但是你想要那些带有这些参数的indentspace在别处使用吗?我不认为这是可能的。