HTML(侧边栏)调用库脚本,可能吗?
我已经在电子表格上用HTML创建了一个边栏,所有这些都工作得很好,但是当移动到维护所有代码的库时,它停止了工作,边栏使用的函数现在未定义,我如何直接从边栏调用库FuncoesOrcamentoV2中的函数?将代码复制到每个电子表格是不切实际的,电子表格有几十个 例如: form.htmlHTML(侧边栏)调用库脚本,可能吗?,html,google-apps-script,google-sheets,sidebar,Html,Google Apps Script,Google Sheets,Sidebar,我已经在电子表格上用HTML创建了一个边栏,所有这些都工作得很好,但是当移动到维护所有代码的库时,它停止了工作,边栏使用的函数现在未定义,我如何直接从边栏调用库FuncoesOrcamentoV2中的函数?将代码复制到每个电子表格是不切实际的,电子表格有几十个 例如: form.html <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<label for="autocomplete">Select a programming language: </label>
<input id="autocomplete" disabled="true" value="Carregando..." clss="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content">
<input type="button" value="Close" onclick="escrever()" />
<script>
function autoCompletar( comps ){
$( "#autocomplete" ).removeAttr("disabled").removeAttr("value");
$( "#autocomplete" ).autocomplete({
source: comps
});
}
google.script.run.withSuccessHandler( autoCompletar ).arrayObjetos(); //arrayObjetos cannot be called
</script>
这不是最优雅的方式,但使用一种形式的eval对我的案例有效: 每张图纸上的代码.gs:
function funcoesOrcamento( funcao, args ){
if(args)
args = args.split("\!|");
else
args = [];
return FuncoesOrcamentoV2[ funcao ].apply(this, args);
}
在HTML侧栏上:
google.script.run.withSuccessHandler( salvaNivelColuna ).funcoesOrcamento( "nivelColuna" );
google.script.run.withSuccessHandler( autoCompletar ).funcoesOrcamento( "arrayObjetos" );
您是否已获得本页中提到的访问该库的权限:?是的,showSideBar函数也在库中。
google.script.run.withSuccessHandler( salvaNivelColuna ).funcoesOrcamento( "nivelColuna" );
google.script.run.withSuccessHandler( autoCompletar ).funcoesOrcamento( "arrayObjetos" );